Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Merge requests
!18
ENH: add is_reference to db.Property
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
ENH: add is_reference to db.Property
f-is-reference
into
dev
Overview
0
Commits
7
Pipelines
2
Changes
3
Merged
Henrik tom Wörden
requested to merge
f-is-reference
into
dev
3 years ago
Overview
0
Commits
7
Pipelines
2
Changes
3
Expand
https://gitlab.com/caosdb/caosdb-pylib/-/merge_requests/63
0
0
Merge request reports
Compare
dev
version 2
df7791cf
3 years ago
version 1
df7791cf
3 years ago
dev (base)
and
latest version
latest version
45bc9778
7 commits,
3 years ago
version 2
df7791cf
6 commits,
3 years ago
version 1
df7791cf
15 commits,
3 years ago
3 files
+
85
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/caosdb/common/models.py
+
37
−
0
Options
@@ -31,6 +31,7 @@ from __future__ import print_function, unicode_literals
import
re
import
sys
from
builtins
import
str
from
copy
import
deepcopy
from
functools
import
cmp_to_key
from
hashlib
import
sha512
from
os
import
listdir
@@ -1504,6 +1505,42 @@ class Property(Entity):
return
super
(
Property
,
self
).
to_xml
(
xml
,
add_properties
)
def
is_reference
(
self
,
server_retrieval
=
False
):
"""
Returns whether this Property is a reference
Parameters
----------
server_retrieval : bool, optional
If True and the datatype is not set, the Property is retrieved from the server, by default False
Returns
-------
bool, NoneType
Returns whether this Property is a reference or None if a server call is needed to
check correctly, but server_retrieval is set to False.
"""
if
self
.
datatype
is
None
:
if
not
self
.
is_valid
():
# this is a workaround to prevent side effects
# since retrieve currently changes the object
if
server_retrieval
:
tmp_prop
=
deepcopy
(
self
)
tmp_prop
.
retrieve
()
return
tmp_prop
.
is_reference
()
else
:
return
None
else
:
# a valid property without datatype has to be an RT
return
True
else
:
return
is_reference
(
self
.
datatype
)
class
Message
(
object
):
Loading