mirror of
https://github.com/yweber/lodel2.git
synced 2025-11-02 04:20:55 +01:00
Continuing mongodb backreference implementation
This commit is contained in:
parent
67bd4087a9
commit
4e90475dbf
4 changed files with 79 additions and 49 deletions
|
|
@ -294,10 +294,11 @@ class Reference(DataHandler):
|
|||
#@return value
|
||||
#@todo implement the check when we have LeObject uid check value
|
||||
def _check_data_value(self, value):
|
||||
value= super()._check_data_value(value)
|
||||
elt = self.__allowed_classes[0]
|
||||
from lodel.leapi.leobject import LeObject
|
||||
value = super()._check_data_value(value)
|
||||
elt = list(self.__allowed_classes)[0]
|
||||
uid = elt.uid_fieldname()[0]# TODO multiple uid is broken
|
||||
if (expt is None and not (isinstance(value, LeObject)) or (value is uid)):
|
||||
if not (hasattr(value, '__class__') and issubclass(value.__class__, LeObject)) or (value is uid):
|
||||
raise FieldValidationError("LeObject instance or id expected for a reference field")
|
||||
return value
|
||||
|
||||
|
|
|
|||
|
|
@ -156,9 +156,9 @@ class LeObject(object):
|
|||
@classmethod
|
||||
def reference_handlers(cls, with_backref = True):
|
||||
return { fname: fdh
|
||||
for fname, fdh in cls.fields(True)
|
||||
if issubclass(fdh, Reference) and \
|
||||
(not with_backref or fdh.backreference is not None)}
|
||||
for fname, fdh in cls.fields(True).items()
|
||||
if issubclass(fdh.__class__, Reference) and \
|
||||
(not with_backref or fdh.back_reference is not None)}
|
||||
|
||||
##@brief Return a LeObject child class from a name
|
||||
# @warning This method has to be called from dynamically generated LeObjects
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue