entity.py
changeset 2656 a93ae0f6c0ad
parent 2650 18aec79ec3a3
child 2658 5535857eeaa5
equal deleted inserted replaced
2655:48cd71bdb5cd 2656:a93ae0f6c0ad
    18 from rql.utils import rqlvar_maker
    18 from rql.utils import rqlvar_maker
    19 
    19 
    20 from cubicweb import Unauthorized
    20 from cubicweb import Unauthorized
    21 from cubicweb.rset import ResultSet
    21 from cubicweb.rset import ResultSet
    22 from cubicweb.selectors import yes
    22 from cubicweb.selectors import yes
    23 from cubicweb.appobject import AppRsetObject
    23 from cubicweb.appobject import AppObject
    24 from cubicweb.schema import RQLVocabularyConstraint, RQLConstraint, bw_normalize_etype
    24 from cubicweb.schema import RQLVocabularyConstraint, RQLConstraint, bw_normalize_etype
    25 
    25 
    26 from cubicweb.common.uilib import printable_value, soup2xhtml
    26 from cubicweb.common.uilib import printable_value, soup2xhtml
    27 from cubicweb.common.mixins import MI_REL_TRIGGERS
    27 from cubicweb.common.mixins import MI_REL_TRIGGERS
    28 from cubicweb.common.mttransforms import ENGINE
    28 from cubicweb.common.mttransforms import ENGINE
   130                     uicfg.autoform_field_kwargs.tag_subject_of(
   130                     uicfg.autoform_field_kwargs.tag_subject_of(
   131                         (etype, rtype, '*'), {'widget': widget})
   131                         (etype, rtype, '*'), {'widget': widget})
   132         return super(_metaentity, mcs).__new__(mcs, name, bases, classdict)
   132         return super(_metaentity, mcs).__new__(mcs, name, bases, classdict)
   133 
   133 
   134 
   134 
   135 class Entity(AppRsetObject, dict):
   135 class Entity(AppObject, dict):
   136     """an entity instance has e_schema automagically set on
   136     """an entity instance has e_schema automagically set on
   137     the class and instances has access to their issuing cursor.
   137     the class and instances has access to their issuing cursor.
   138 
   138 
   139     A property is set for each attribute and relation on each entity's type
   139     A property is set for each attribute and relation on each entity's type
   140     class. Becare that among attributes, 'eid' is *NEITHER* stored in the
   140     class. Becare that among attributes, 'eid' is *NEITHER* stored in the
   298         if mainattr == 'eid':
   298         if mainattr == 'eid':
   299             needcheck = False
   299             needcheck = False
   300         return mainattr, needcheck
   300         return mainattr, needcheck
   301 
   301 
   302     def __init__(self, req, rset=None, row=None, col=0):
   302     def __init__(self, req, rset=None, row=None, col=0):
   303         AppRsetObject.__init__(self, req, rset, row, col)
   303         AppObject.__init__(self, req, rset, row, col)
   304         dict.__init__(self)
   304         dict.__init__(self)
   305         self._related_cache = {}
   305         self._related_cache = {}
   306         if rset is not None:
   306         if rset is not None:
   307             self.eid = rset[row][col]
   307             self.eid = rset[row][col]
   308         else:
   308         else: