use __regid__ instead of id on appobject classes
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 23 Sep 2009 10:20:51 +0200
changeset 3399 2b84f4adb6f8
parent 3398 d84b0176452c
child 3400 93fc0070673a
use __regid__ instead of id on appobject classes
appobject.py
hooks/metadata.py
selectors.py
server/sources/native.py
--- a/appobject.py	Wed Sep 23 10:19:35 2009 +0200
+++ b/appobject.py	Wed Sep 23 10:20:51 2009 +0200
@@ -298,7 +298,7 @@
         """return cw property key for the property of the given id for this
         class
         """
-        return '%s.%s.%s' % (cls.__registry__, cls.id, propid)
+        return '%s.%s.%s' % (cls.__registry__, cls.__regid__, propid)
 
     def cw_propval(self, propid):
         """return cw property value associated to key
--- a/hooks/metadata.py	Wed Sep 23 10:19:35 2009 +0200
+++ b/hooks/metadata.py	Wed Sep 23 10:20:51 2009 +0200
@@ -81,7 +81,7 @@
         entity = self.entity
         try:
             session.add_relation(entity.eid, 'is',
-                                 eschema_type_eid(session, entity.id))
+                                 eschema_type_eid(session, entity.__regid__))
         except IndexError:
             # during schema serialization, skip
             return
--- a/selectors.py	Wed Sep 23 10:19:35 2009 +0200
+++ b/selectors.py	Wed Sep 23 10:20:51 2009 +0200
@@ -119,7 +119,7 @@
     """
     if getattr(iface, '__registry__', None) == 'etypes':
         # adjust score if the interface is an entity class
-        parents = etypesreg.parent_classes(cls_or_inst.id)
+        parents = etypesreg.parent_classes(cls_or_inst.__regid__)
         if iface is cls:
             return len(parents) + 4
         if iface is parents[-1]: # Any
@@ -427,7 +427,8 @@
     * context (`basestring`) is matching the context property value for the
       given cls
     """
-    propval = req.property_value('%s.%s.context' % (cls.__registry__, cls.id))
+    propval = req.property_value('%s.%s.context' % (cls.__registry__,
+                                                    cls.__regid__))
     if not propval:
         propval = cls.context
     if context is not None and propval and context != propval:
@@ -542,7 +543,7 @@
     """
     @lltrace
     def __call__(self, cls, req, rset=None, row=None, col=0, view=None, **kwargs):
-        if view is None or not view.id in self.expected:
+        if view is None or not view.__regid__ in self.expected:
             return 0
         return 1
 
--- a/server/sources/native.py	Wed Sep 23 10:19:35 2009 +0200
+++ b/server/sources/native.py	Wed Sep 23 10:20:51 2009 +0200
@@ -531,7 +531,7 @@
         if extid is not None:
             assert isinstance(extid, str)
             extid = b64encode(extid)
-        attrs = {'type': entity.id, 'eid': entity.eid, 'extid': extid,
+        attrs = {'type': entity.__regid__, 'eid': entity.eid, 'extid': extid,
                  'source': source.uri, 'mtime': datetime.now()}
         session.system_sql(self.sqlgen.insert('entities', attrs), attrs)