Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
d73f94d5
Commit
d73f94d5
authored
Mar 28, 2018
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better handling of hyperdata modification
parent
6ebdc37e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
nodes.py
gargantext/models/nodes.py
+15
-5
No files found.
gargantext/models/nodes.py
View file @
d73f94d5
...
@@ -10,6 +10,9 @@ from .users import User
...
@@ -10,6 +10,9 @@ from .users import User
__all__
=
[
'Node'
,
'NodeNode'
,
'CorpusNode'
,
'DocumentNode'
]
__all__
=
[
'Node'
,
'NodeNode'
,
'CorpusNode'
,
'DocumentNode'
]
_UNDEFINED
=
object
()
class
NodeType
(
TypeDecorator
):
class
NodeType
(
TypeDecorator
):
"""Define a new type of column to describe a Node's type.
"""Define a new type of column to describe a Node's type.
Internally, this column type is implemented as an SQL integer.
Internally, this column type is implemented as an SQL integer.
...
@@ -102,14 +105,21 @@ class Node(ValidatorMixin, Base):
...
@@ -102,14 +105,21 @@ class Node(ValidatorMixin, Base):
Base
.
__init__
(
self
,
**
kwargs
)
Base
.
__init__
(
self
,
**
kwargs
)
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
"""Allow direct access to hyperdata via the bracket operator.
"""Allow direct access to hyperdata via the bracket operator."""
"""
return
self
.
hyperdata
[
key
]
return
self
.
hyperdata
[
key
]
def
__setitem__
(
self
,
key
,
value
):
def
__setitem__
(
self
,
key
,
value
):
"""Allow direct access to hyperdata via the bracket operator.
"""Allow direct access to hyperdata via the bracket operator."""
"""
old_value
=
self
.
hyperdata
.
get
(
key
,
_UNDEFINED
)
self
.
hyperdata
[
key
]
=
value
if
old_value
!=
value
:
self
.
hyperdata
[
key
]
=
value
flag_modified
(
self
,
'hyperdata'
)
def
__delitem
(
self
,
key
):
"""Allow direct access to hyperdata via the bracket operator."""
if
key
in
self
.
hyperdata
:
del
self
.
hyperdata
[
key
]
flag_modified
(
self
,
'hyperdata'
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<{0.__class__.__name__}(id={0.id}, typename={0.typename!r}, '
\
return
'<{0.__class__.__name__}(id={0.id}, typename={0.typename!r}, '
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment