[entity] continue cleanup of Entity/AnyEntity namespace
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 20 May 2010 20:50:00 +0200
changeset 5557 1a534c596bff
parent 5556 9ab2b4c74baf
child 5558 afd1face1faf
[entity] continue cleanup of Entity/AnyEntity namespace * prefix by cw_ or _cw all '2nd zone' attributes / methods, other most commonly used will be done later (some methods used by client are made private anyway when they are for internal purpose anyway) * kill set_eid, use direct affectation instead * kill the auto-transmutation feature (pre_add_hook), hence releasing 3.9 will require releasing file cube as well
dataimport.py
devtools/testlib.py
entities/__init__.py
entities/test/unittest_wfobjs.py
entities/wfobjs.py
entity.py
goa/db.py
goa/gaesource.py
goa/test/unittest_rql.py
hooks/bookmark.py
hooks/security.py
mixins.py
rset.py
selectors.py
server/repository.py
server/session.py
server/sources/__init__.py
server/sources/native.py
server/ssplanner.py
server/test/unittest_multisources.py
server/test/unittest_security.py
server/test/unittest_storage.py
server/test/unittest_undo.py
test/unittest_entity.py
test/unittest_rset.py
web/formfields.py
web/views/autoform.py
web/views/editcontroller.py
web/views/editforms.py
web/views/editviews.py
web/views/treeview.py
--- a/dataimport.py	Thu May 20 20:47:55 2010 +0200
+++ b/dataimport.py	Thu May 20 20:50:00 2010 +0200
@@ -584,7 +584,7 @@
             kwargs[k] = getattr(v, 'eid', v)
         entity, rels = self.metagen.base_etype_dicts(etype)
         entity = copy(entity)
-        entity._related_cache = {}
+        entity.cw_clear_relation_cache()
         self.metagen.init_entity(entity)
         entity.update(kwargs)
         entity.edited_attributes = set(entity)
--- a/devtools/testlib.py	Thu May 20 20:47:55 2010 +0200
+++ b/devtools/testlib.py	Thu May 20 20:50:00 2010 +0200
@@ -306,7 +306,7 @@
         req.execute('SET X in_group G WHERE X eid %%(x)s, G name IN(%s)'
                     % ','.join(repr(g) for g in groups),
                     {'x': user.eid})
-        user.clear_related_cache('in_group', 'subject')
+        user.cw_clear_relation_cache('in_group', 'subject')
         if commit:
             req.cnx.commit()
         return user
--- a/entities/__init__.py	Thu May 20 20:47:55 2010 +0200
+++ b/entities/__init__.py	Thu May 20 20:50:00 2010 +0200
@@ -42,7 +42,7 @@
         for rschema, attrschema in self.e_schema.attribute_definitions():
             if rschema.meta:
                 continue
-            value = self.get_value(rschema.type)
+            value = self.cw_attr_value(rschema.type)
             if value:
                 # make the value printable (dates, floats, bytes, etc.)
                 return self.printable_value(rschema.type, value, attrschema.type,
@@ -107,7 +107,7 @@
         """
         if rtype is None:
             return self.dc_title().lower()
-        value = self.get_value(rtype)
+        value = self.cw_attr_value(rtype)
         # do not restrict to `unicode` because Bytes will return a `str` value
         if isinstance(value, basestring):
             return self.printable_value(rtype, format='text/plain').lower()
--- a/entities/test/unittest_wfobjs.py	Thu May 20 20:47:55 2010 +0200
+++ b/entities/test/unittest_wfobjs.py	Thu May 20 20:50:00 2010 +0200
@@ -108,7 +108,7 @@
         self.commit()
         iworkflowable.change_state('deactivated', u'deactivate 2')
         self.commit()
-        e.clear_related_cache('wf_info_for', 'object')
+        e.cw_clear_relation_cache('wf_info_for', 'object')
         self.assertEquals([tr.comment for tr in e.reverse_wf_info_for],
                           ['deactivate 1', 'activate 1', 'deactivate 2'])
         self.assertEquals(iworkflowable.latest_trinfo().comment, 'deactivate 2')
@@ -128,7 +128,7 @@
 
     def _test_manager_deactivate(self, user):
         iworkflowable = user.cw_adapt_to('IWorkflowable')
-        user.clear_related_cache('in_state', 'subject')
+        user.cw_clear_relation_cache('in_state', 'subject')
         self.assertEquals(len(user.in_state), 1)
         self.assertEquals(iworkflowable.state, 'deactivated')
         trinfo = iworkflowable.latest_trinfo()
--- a/entities/wfobjs.py	Thu May 20 20:47:55 2010 +0200
+++ b/entities/wfobjs.py	Thu May 20 20:50:00 2010 +0200
@@ -173,7 +173,7 @@
                 {'os': todelstate.eid, 'ns': replacement.eid})
         execute('SET X to_state NS WHERE X to_state OS, OS eid %(os)s, NS eid %(ns)s',
                 {'os': todelstate.eid, 'ns': replacement.eid})
-        todelstate.delete()
+        todelstate.cw_delete()
 
 
 class BaseTransition(AnyEntity):
--- a/entity.py	Thu May 20 20:47:55 2010 +0200
+++ b/entity.py	Thu May 20 20:50:00 2010 +0200
@@ -15,16 +15,15 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""Base class for entity objects manipulated in clients
+"""Base class for entity objects manipulated in clients"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 from warnings import warn
 
 from logilab.common import interface
-from logilab.common.compat import all
 from logilab.common.decorators import cached
+from logilab.common.deprecation import deprecated
 from logilab.mtconverter import TransformData, TransformError, xml_escape
 
 from rql.utils import rqlvar_maker
@@ -289,12 +288,12 @@
     def __init__(self, req, rset=None, row=None, col=0):
         AppObject.__init__(self, req, rset=rset, row=row, col=col)
         dict.__init__(self)
-        self._related_cache = {}
+        self._cw_related_cache = {}
         if rset is not None:
             self.eid = rset[row][col]
         else:
             self.eid = None
-        self._is_saved = True
+        self._cw_is_saved = True
 
     def __repr__(self):
         return '<Entity %s %s %s at %s>' % (
@@ -413,27 +412,7 @@
             cache[interface] = adapter
             return adapter
 
-    def rql_set_value(self, attr, value):
-        """call by rql execution plan when some attribute is modified
-
-        don't use dict api in such case since we don't want attribute to be
-        added to skip_security_attributes.
-        """
-        super(Entity, self).__setitem__(attr, value)
-
-    def pre_add_hook(self):
-        """hook called by the repository before doing anything to add the entity
-        (before_add entity hooks have not been called yet). This give the
-        occasion to do weird stuff such as autocast (File -> Image for instance).
-
-        This method must return the actual entity to be added.
-        """
-        return self
-
-    def set_eid(self, eid):
-        self.eid = eid
-
-    def has_eid(self):
+    def has_eid(self): # XXX cw_has_eid
         """return True if the entity has an attributed eid (False
         meaning that the entity has to be created
         """
@@ -443,38 +422,34 @@
         except (ValueError, TypeError):
             return False
 
-    def is_saved(self):
+    def cw_is_saved(self):
         """during entity creation, there is some time during which the entity
-        has an eid attributed though it's not saved (eg during before_add_entity
-        hooks). You can use this method to ensure the entity has an eid *and* is
-        saved in its source.
+        has an eid attributed though it's not saved (eg during
+        'before_add_entity' hooks). You can use this method to ensure the entity
+        has an eid *and* is saved in its source.
         """
-        return self.has_eid() and self._is_saved
+        return self.has_eid() and self._cw_is_saved
 
     @cached
-    def metainformation(self):
+    def cw_metainformation(self):
         res = dict(zip(('type', 'source', 'extid'), self._cw.describe(self.eid)))
         res['source'] = self._cw.source_defs()[res['source']]
         return res
 
-    def clear_local_perm_cache(self, action):
-        for rqlexpr in self.e_schema.get_rqlexprs(action):
-            self._cw.local_perm_cache.pop((rqlexpr.eid, (('x', self.eid),)), None)
-
-    def check_perm(self, action):
+    def cw_check_perm(self, action):
         self.e_schema.check_perm(self._cw, action, eid=self.eid)
 
-    def has_perm(self, action):
+    def cw_has_perm(self, action):
         return self.e_schema.has_perm(self._cw, action, eid=self.eid)
 
-    def view(self, __vid, __registry='views', w=None, **kwargs):
+    def view(self, __vid, __registry='views', w=None, **kwargs): # XXX cw_view
         """shortcut to apply a view on this entity"""
         view = self._cw.vreg[__registry].select(__vid, self._cw, rset=self.cw_rset,
                                                 row=self.cw_row, col=self.cw_col,
                                                 **kwargs)
         return view.render(row=self.cw_row, col=self.cw_col, w=w, **kwargs)
 
-    def absolute_url(self, *args, **kwargs):
+    def absolute_url(self, *args, **kwargs): # XXX cw_url
         """return an absolute url to view this entity"""
         # use *args since we don't want first argument to be "anonymous" to
         # avoid potential clash with kwargs
@@ -487,7 +462,7 @@
         # the object for use in the relation is tricky
         # XXX search_state is web specific
         if getattr(self._cw, 'search_state', ('normal',))[0] == 'normal':
-            kwargs['base_url'] = self.metainformation()['source'].get('base-url')
+            kwargs['base_url'] = self.cw_metainformation()['source'].get('base-url')
         if method in (None, 'view'):
             try:
                 kwargs['_restpath'] = self.rest_path(kwargs.get('base_url'))
@@ -499,7 +474,7 @@
             kwargs['rql'] = 'Any X WHERE X eid %s' % self.eid
         return self._cw.build_url(method, **kwargs)
 
-    def rest_path(self, use_ext_eid=False):
+    def rest_path(self, use_ext_eid=False): # XXX cw_rest_path
         """returns a REST-like (relative) path for this entity"""
         mainattr, needcheck = self._rest_attr_info()
         etype = str(self.e_schema)
@@ -522,12 +497,12 @@
                     path += '/eid'
         if mainattr == 'eid':
             if use_ext_eid:
-                value = self.metainformation()['extid']
+                value = self.cw_metainformation()['extid']
             else:
                 value = self.eid
         return '%s/%s' % (path, self._cw.url_quote(value))
 
-    def attr_metadata(self, attr, metadata):
+    def cw_attr_metadata(self, attr, metadata):
         """return a metadata for an attribute (None if unspecified)"""
         value = getattr(self, '%s_%s' % (attr, metadata), None)
         if value is None and metadata == 'encoding':
@@ -535,7 +510,7 @@
         return value
 
     def printable_value(self, attr, value=_marker, attrtype=None,
-                        format='text/html', displaytime=True):
+                        format='text/html', displaytime=True): # XXX cw_printable_value
         """return a displayable value (i.e. unicode string) which may contains
         html tags
         """
@@ -554,16 +529,16 @@
             # description...
             if props.internationalizable:
                 value = self._cw._(value)
-            attrformat = self.attr_metadata(attr, 'format')
+            attrformat = self.cw_attr_metadata(attr, 'format')
             if attrformat:
-                return self.mtc_transform(value, attrformat, format,
-                                          self._cw.encoding)
+                return self._cw_mtc_transform(value, attrformat, format,
+                                              self._cw.encoding)
         elif attrtype == 'Bytes':
-            attrformat = self.attr_metadata(attr, 'format')
+            attrformat = self.cw_attr_metadata(attr, 'format')
             if attrformat:
-                encoding = self.attr_metadata(attr, 'encoding')
-                return self.mtc_transform(value.getvalue(), attrformat, format,
-                                          encoding)
+                encoding = self.cw_attr_metadata(attr, 'encoding')
+                return self._cw_mtc_transform(value.getvalue(), attrformat, format,
+                                              encoding)
             return u''
         value = printable_value(self._cw, attrtype, value, props,
                                 displaytime=displaytime)
@@ -571,8 +546,8 @@
             value = xml_escape(value)
         return value
 
-    def mtc_transform(self, data, format, target_format, encoding,
-                      _engine=ENGINE):
+    def _cw_mtc_transform(self, data, format, target_format, encoding,
+                          _engine=ENGINE):
         trdata = TransformData(data, format, encoding, appobject=self)
         data = _engine.convert(trdata, target_format).decode()
         if format == 'text/html':
@@ -581,7 +556,7 @@
 
     # entity cloning ##########################################################
 
-    def copy_relations(self, ceid):
+    def copy_relations(self, ceid): # XXX cw_copy_relations
         """copy relations of the object with the given eid on this
         object (this method is called on the newly created copy, and
         ceid designates the original entity).
@@ -610,7 +585,7 @@
             rql = 'SET X %s V WHERE X eid %%(x)s, Y eid %%(y)s, Y %s V' % (
                 rschema.type, rschema.type)
             execute(rql, {'x': self.eid, 'y': ceid})
-            self.clear_related_cache(rschema.type, 'subject')
+            self.cw_clear_relation_cache(rschema.type, 'subject')
         for rschema in self.e_schema.object_relations():
             if rschema.meta:
                 continue
@@ -628,19 +603,19 @@
             rql = 'SET V %s X WHERE X eid %%(x)s, Y eid %%(y)s, V %s Y' % (
                 rschema.type, rschema.type)
             execute(rql, {'x': self.eid, 'y': ceid})
-            self.clear_related_cache(rschema.type, 'object')
+            self.cw_clear_relation_cache(rschema.type, 'object')
 
     # data fetching methods ###################################################
 
     @cached
-    def as_rset(self):
+    def as_rset(self): # XXX .cw_as_rset
         """returns a resultset containing `self` information"""
         rset = ResultSet([(self.eid,)], 'Any X WHERE X eid %(x)s',
                          {'x': self.eid}, [(self.__regid__,)])
         rset.req = self._cw
         return rset
 
-    def to_complete_relations(self):
+    def _cw_to_complete_relations(self):
         """by default complete final relations to when calling .complete()"""
         for rschema in self.e_schema.subject_relations():
             if rschema.final:
@@ -657,7 +632,7 @@
                    all(matching_groups(e.get_groups('read')) for e in targets):
                     yield rschema, 'subject'
 
-    def to_complete_attributes(self, skip_bytes=True, skip_pwd=True):
+    def _cw_to_complete_attributes(self, skip_bytes=True, skip_pwd=True):
         for rschema, attrschema in self.e_schema.attribute_definitions():
             # skip binary data by default
             if skip_bytes and attrschema.type == 'Bytes':
@@ -674,7 +649,7 @@
             yield attr
 
     _cw_completed = False
-    def complete(self, attributes=None, skip_bytes=True, skip_pwd=True):
+    def complete(self, attributes=None, skip_bytes=True, skip_pwd=True): # XXX cw_complete
         """complete this entity by adding missing attributes (i.e. query the
         repository to fill the entity)
 
@@ -691,7 +666,7 @@
         V = varmaker.next()
         rql = ['WHERE %s eid %%(x)s' % V]
         selected = []
-        for attr in (attributes or self.to_complete_attributes(skip_bytes, skip_pwd)):
+        for attr in (attributes or self._cw_to_complete_attributes(skip_bytes, skip_pwd)):
             # if attribute already in entity, nothing to do
             if self.has_key(attr):
                 continue
@@ -703,9 +678,9 @@
         lastattr = len(selected) + 1
         if attributes is None:
             # fetch additional relations (restricted to 0..1 relations)
-            for rschema, role in self.to_complete_relations():
+            for rschema, role in self._cw_to_complete_relations():
                 rtype = rschema.type
-                if self.relation_cached(rtype, role):
+                if self.cw_relation_cached(rtype, role):
                     continue
                 var = varmaker.next()
                 targettype = rschema.targets(self.e_schema, role)[0]
@@ -742,9 +717,9 @@
                     rrset.req = self._cw
                 else:
                     rrset = self._cw.eid_rset(value)
-                self.set_related_cache(rtype, role, rrset)
+                self.cw_set_relation_cache(rtype, role, rrset)
 
-    def get_value(self, name):
+    def cw_attr_value(self, name):
         """get value for the attribute relation <name>, query the repository
         to get the value if necessary.
 
@@ -754,7 +729,7 @@
         try:
             value = self[name]
         except KeyError:
-            if not self.is_saved():
+            if not self.cw_is_saved():
                 return None
             rql = "Any A WHERE X eid %%(x)s, X %s A" % name
             try:
@@ -776,7 +751,7 @@
                         self[name] = value = None
         return value
 
-    def related(self, rtype, role='subject', limit=None, entities=False):
+    def related(self, rtype, role='subject', limit=None, entities=False): # XXX .cw_related
         """returns a resultset of related entities
 
         :param role: is the role played by 'self' in the relation ('subject' or 'object')
@@ -784,16 +759,16 @@
         :param entities: if True, the entites are returned; if False, a result set is returned
         """
         try:
-            return self.related_cache(rtype, role, entities, limit)
+            return self._cw_relation_cache(rtype, role, entities, limit)
         except KeyError:
             pass
         assert self.has_eid()
-        rql = self.related_rql(rtype, role)
+        rql = self.cw_related_rql(rtype, role)
         rset = self._cw.execute(rql, {'x': self.eid})
-        self.set_related_cache(rtype, role, rset)
+        self.cw_set_relation_cache(rtype, role, rset)
         return self.related(rtype, role, limit, entities)
 
-    def related_rql(self, rtype, role='subject', targettypes=None):
+    def cw_related_rql(self, rtype, role='subject', targettypes=None):
         rschema = self._cw.vreg.schema[rtype]
         if role == 'subject':
             restriction = 'E eid %%(x)s, E %s X' % rtype
@@ -842,7 +817,7 @@
 
     # generic vocabulary methods ##############################################
 
-    def unrelated_rql(self, rtype, targettype, role, ordermethod=None,
+    def cw_unrelated_rql(self, rtype, targettype, role, ordermethod=None,
                       vocabconstraints=True):
         """build a rql to fetch `targettype` entities unrelated to this entity
         using (rtype, role) relation.
@@ -904,12 +879,12 @@
         return rql, args
 
     def unrelated(self, rtype, targettype, role='subject', limit=None,
-                  ordermethod=None):
+                  ordermethod=None): # XXX .cw_unrelated
         """return a result set of target type objects that may be related
         by a given relation, with self as subject or object
         """
         try:
-            rql, args = self.unrelated_rql(rtype, targettype, role, ordermethod)
+            rql, args = self.cw_unrelated_rql(rtype, targettype, role, ordermethod)
         except Unauthorized:
             return self._cw.empty_rset()
         if limit is not None:
@@ -917,18 +892,19 @@
             rql = '%s LIMIT %s WHERE %s' % (before, limit, after)
         return self._cw.execute(rql, args)
 
-    # relations cache handling ################################################
+    # relations cache handling #################################################
 
-    def relation_cached(self, rtype, role):
-        """return true if the given relation is already cached on the instance
+    def cw_relation_cached(self, rtype, role):
+        """return None if the given relation isn't already cached on the
+        instance, else the content of the cache (a 2-uple (rset, entities)).
         """
-        return self._related_cache.get('%s_%s' % (rtype, role))
+        return self._cw_related_cache.get('%s_%s' % (rtype, role))
 
-    def related_cache(self, rtype, role, entities=True, limit=None):
+    def _cw_relation_cache(self, rtype, role, entities=True, limit=None):
         """return values for the given relation if it's cached on the instance,
         else raise `KeyError`
         """
-        res = self._related_cache['%s_%s' % (rtype, role)][entities]
+        res = self._cw_related_cache['%s_%s' % (rtype, role)][entities]
         if limit is not None and limit < len(res):
             if entities:
                 res = res[:limit]
@@ -936,10 +912,10 @@
                 res = res.limit(limit)
         return res
 
-    def set_related_cache(self, rtype, role, rset, col=0):
+    def cw_set_relation_cache(self, rtype, role, rset):
         """set cached values for the given relation"""
         if rset:
-            related = list(rset.entities(col))
+            related = list(rset.entities(0))
             rschema = self._cw.vreg.schema.rschema(rtype)
             if role == 'subject':
                 rcard = rschema.rdef(self.e_schema, related[0].e_schema).cardinality[1]
@@ -949,23 +925,23 @@
                 target = 'subject'
             if rcard in '?1':
                 for rentity in related:
-                    rentity._related_cache['%s_%s' % (rtype, target)] = (
+                    rentity._cw_related_cache['%s_%s' % (rtype, target)] = (
                         self.as_rset(), (self,))
         else:
             related = ()
-        self._related_cache['%s_%s' % (rtype, role)] = (rset, related)
+        self._cw_related_cache['%s_%s' % (rtype, role)] = (rset, related)
 
-    def clear_related_cache(self, rtype=None, role=None):
+    def cw_clear_relation_cache(self, rtype=None, role=None):
         """clear cached values for the given relation or the entire cache if
         no relation is given
         """
         if rtype is None:
-            self._related_cache = {}
+            self._cw_related_cache = {}
         else:
             assert role
-            self._related_cache.pop('%s_%s' % (rtype, role), None)
+            self._cw_related_cache.pop('%s_%s' % (rtype, role), None)
 
-    def clear_all_caches(self):
+    def clear_all_caches(self): # XXX cw_clear_all_caches
         """flush all caches on this entity. Further attributes/relations access
         will triggers new database queries to get back values.
 
@@ -978,7 +954,7 @@
         self.clear()
         # clear relations cache
         for rschema, _, role in self.e_schema.relation_definitions():
-            self.clear_related_cache(rschema.type, role)
+            self.cw_clear_relation_cache(rschema.type, role)
         # rest path unique cache
         try:
             del self.__unique
@@ -991,10 +967,10 @@
 
     # raw edition utilities ###################################################
 
-    def set_attributes(self, **kwargs):
+    def set_attributes(self, **kwargs): # XXX cw_set_attributes
         _check_cw_unsafe(kwargs)
         assert kwargs
-        assert self._is_saved, "should not call set_attributes while entity "\
+        assert self.cw_is_saved(), "should not call set_attributes while entity "\
                "hasn't been saved yet"
         relations = []
         for key in kwargs:
@@ -1009,7 +985,7 @@
         # edited_attributes / skip_security_attributes machinery
         self.update(kwargs)
 
-    def set_relations(self, **kwargs):
+    def set_relations(self, **kwargs): # XXX cw_set_relations
         """add relations to the given object. To set a relation where this entity
         is the object of the relation, use 'reverse_'<relation> as argument name.
 
@@ -1033,28 +1009,42 @@
                 restr, ','.join(str(r.eid) for r in values)),
                              {'x': self.eid})
 
-    def delete(self, **kwargs):
+    def cw_delete(self, **kwargs):
         assert self.has_eid(), self.eid
         self._cw.execute('DELETE %s X WHERE X eid %%(x)s' % self.e_schema,
                          {'x': self.eid}, **kwargs)
 
     # server side utilities ###################################################
 
+    def _cw_rql_set_value(self, attr, value):
+        """call by rql execution plan when some attribute is modified
+
+        don't use dict api in such case since we don't want attribute to be
+        added to skip_security_attributes.
+
+        This method is for internal use, you should not use it.
+        """
+        super(Entity, self).__setitem__(attr, value)
+
+    def _cw_clear_local_perm_cache(self, action):
+        for rqlexpr in self.e_schema.get_rqlexprs(action):
+            self._cw.local_perm_cache.pop((rqlexpr.eid, (('x', self.eid),)), None)
+
     @property
-    def skip_security_attributes(self):
+    def _cw_skip_security_attributes(self):
         try:
-            return self._skip_security_attributes
+            return self.__cw_skip_security_attributes
         except:
-            self._skip_security_attributes = set()
-            return self._skip_security_attributes
+            self.__cw_skip_security_attributes = set()
+            return self.__cw_skip_security_attributes
 
-    def set_defaults(self):
+    def _cw_set_defaults(self):
         """set default values according to the schema"""
         for attr, value in self.e_schema.defaults():
             if not self.has_key(attr):
                 self[str(attr)] = value
 
-    def check(self, creation=False):
+    def _cw_check(self, creation=False):
         """check this entity against its schema. Only final relation
         are checked here, constraint on actual relations are checked in hooks
         """
@@ -1077,6 +1067,29 @@
         self.e_schema.check(self, creation=creation, _=_,
                             relations=relations)
 
+    @deprecated('[3.9] use entity.cw_attr_value(attr)')
+    def get_value(self, name):
+        return self.cw_attr_value(name)
+
+    @deprecated('[3.9] use entity.cw_delete()')
+    def delete(self, **kwargs):
+        return self.cw_delete(**kwargs)
+
+    @deprecated('[3.9] use entity.cw_attr_metadata(attr, metadata)')
+    def attr_metadata(self, attr, metadata):
+        return self.cw_attr_metadata(attr, metadata)
+
+    @deprecated('[3.9] use entity.cw_has_perm(action)')
+    def has_perm(self, action):
+        return self.cw_has_perm(action)
+
+    @deprecated('[3.9] use entity.cw_set_relation_cache(rtype, role, rset)')
+    def set_related_cache(self, rtype, role, rset):
+        self.cw_set_relation_cache(rtype, role, rset)
+
+    @deprecated('[3.9] use entity.cw_clear_relation_cache(rtype, role, rset)')
+    def clear_related_cache(self, rtype=None, role=None):
+        self.cw_clear_relation_cache(rtype, role)
 
 # attribute and relation descriptors ##########################################
 
@@ -1090,7 +1103,7 @@
     def __get__(self, eobj, eclass):
         if eobj is None:
             return self
-        return eobj.get_value(self._attrname)
+        return eobj.cw_attr_value(self._attrname)
 
     def __set__(self, eobj, value):
         eobj[self._attrname] = value
--- a/goa/db.py	Thu May 20 20:47:55 2010 +0200
+++ b/goa/db.py	Thu May 20 20:50:00 2010 +0200
@@ -233,7 +233,7 @@
                 return self.req.datastore_get(self.eid)
             except AttributeError: # self.req is not a server session
                 return Get(self.eid)
-        self.set_defaults()
+        self._cw_set_defaults()
         values = self._to_gae_dict(convert=False)
         parent = key_name = _app = None
         if self._gaeinitargs is not None:
@@ -343,7 +343,7 @@
             self.req = req
         dbmodel = self.to_gae_model()
         key = Put(dbmodel)
-        self.set_eid(str(key))
+        self.eid = str(key)
         if self.req is not None and self.rset is None:
             self.rset = rset_from_objs(self.req, dbmodel, ('eid',),
                                        'Any X WHERE X eid %(x)s', {'x': self.eid})
@@ -409,7 +409,7 @@
     def dynamic_properties(self):
         raise NotImplementedError('use eschema')
 
-    def is_saved(self):
+    def cw_is_saved(self):
         return self.has_eid()
 
     def parent(self):
--- a/goa/gaesource.py	Thu May 20 20:47:55 2010 +0200
+++ b/goa/gaesource.py	Thu May 20 20:50:00 2010 +0200
@@ -49,15 +49,15 @@
         except KeyError:
             pass
         else:
-            entity.clear_related_cache(rtype, role)
+            entity.cw_clear_relation_cache(rtype, role)
     if gaesubject.kind() == 'CWUser':
         for asession in session.repo._sessions.itervalues():
             if asession.user.eid == subject:
-                asession.user.clear_related_cache(rtype, 'subject')
+                asession.user.cw_clear_relation_cache(rtype, 'subject')
     if gaeobject.kind() == 'CWUser':
         for asession in session.repo._sessions.itervalues():
             if asession.user.eid == object:
-                asession.user.clear_related_cache(rtype, 'object')
+                asession.user.cw_clear_relation_cache(rtype, 'object')
 
 def _mark_modified(session, gaeentity):
     modified = session.transaction_data.setdefault('modifiedentities', {})
--- a/goa/test/unittest_rql.py	Thu May 20 20:47:55 2010 +0200
+++ b/goa/test/unittest_rql.py	Thu May 20 20:50:00 2010 +0200
@@ -15,9 +15,6 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""
-
-"""
 from cubicweb.goa.testlib import *
 
 from cubicweb import Binary
@@ -612,7 +609,7 @@
     def test_error_unknown_eid(self):
         rset = self.req.execute('Any X WHERE X eid %(x)s', {'x': '1234'})
         self.assertEquals(len(rset), 0)
-        self.blog.delete()
+        self.blog.cw_delete()
         rset = self.req.execute('Any X WHERE X eid %(x)s', {'x': self.blog.eid})
         self.assertEquals(len(rset), 0)
 
--- a/hooks/bookmark.py	Thu May 20 20:47:55 2010 +0200
+++ b/hooks/bookmark.py	Thu May 20 20:50:00 2010 +0200
@@ -15,9 +15,8 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""bookmark related hooks
+"""bookmark related hooks"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 from cubicweb.server import hook
@@ -28,7 +27,7 @@
     def precommit_event(self):
         if not self.session.deleted_in_transaction(self.bookmark.eid):
             if not self.bookmark.bookmarked_by:
-                self.bookmark.delete()
+                self.bookmark.cw_delete()
 
 
 class DelBookmarkedByHook(hook.Hook):
--- a/hooks/security.py	Thu May 20 20:47:55 2010 +0200
+++ b/hooks/security.py	Thu May 20 20:50:00 2010 +0200
@@ -29,9 +29,9 @@
 def check_entity_attributes(session, entity, editedattrs=None):
     eid = entity.eid
     eschema = entity.e_schema
-    # .skip_security_attributes is there to bypass security for attributes
+    # ._cw_skip_security_attributes is there to bypass security for attributes
     # set by hooks by modifying the entity's dictionnary
-    dontcheck = entity.skip_security_attributes
+    dontcheck = entity._cw_skip_security_attributes
     if editedattrs is None:
         try:
             editedattrs = entity.edited_attributes
@@ -57,7 +57,7 @@
         for values in session.transaction_data.pop('check_entity_perm_op'):
             entity = session.entity_from_eid(values[0])
             action = values[1]
-            entity.check_perm(action)
+            entity.cw_check_perm(action)
             check_entity_attributes(session, entity, values[2:])
 
     def commit_event(self):
@@ -105,10 +105,10 @@
     def __call__(self):
         try:
             # check user has permission right now, if not retry at commit time
-            self.entity.check_perm('update')
+            self.entity.cw_check_perm('update')
             check_entity_attributes(self._cw, self.entity)
         except Unauthorized:
-            self.entity.clear_local_perm_cache('update')
+            self.entity._cw_clear_local_perm_cache('update')
             # save back editedattrs in case the entity is reedited later in the
             # same transaction, which will lead to edited_attributes being
             # overwritten
@@ -122,7 +122,7 @@
     events = ('before_delete_entity',)
 
     def __call__(self):
-        self.entity.check_perm('delete')
+        self.entity.cw_check_perm('delete')
 
 
 class BeforeAddRelationSecurityHook(SecurityHook):
--- a/mixins.py	Thu May 20 20:47:55 2010 +0200
+++ b/mixins.py	Thu May 20 20:50:00 2010 +0200
@@ -145,7 +145,7 @@
                                 entities=entities)
 
     def children_rql(self):
-        return self.related_rql(self.tree_attribute, self.children_target)
+        return self.cw_related_rql(self.tree_attribute, self.children_target)
 
     def is_leaf(self):
         return len(self.children()) == 0
--- a/rset.py	Thu May 20 20:47:55 2010 +0200
+++ b/rset.py	Thu May 20 20:50:00 2010 +0200
@@ -453,7 +453,7 @@
         etype = self.description[row][col]
         entity = self.req.vreg['etypes'].etype_class(etype)(req, rset=self,
                                                             row=row, col=col)
-        entity.set_eid(eid)
+        entity.eid = eid
         # cache entity
         req.set_entity_cache(entity)
         eschema = entity.e_schema
@@ -494,7 +494,7 @@
                         rrset.req = req
                     else:
                         rrset = self._build_entity(row, outerselidx).as_rset()
-                    entity.set_related_cache(attr, role, rrset)
+                    entity.cw_set_relation_cache(attr, role, rrset)
         return entity
 
     @cached
--- a/selectors.py	Thu May 20 20:47:55 2010 +0200
+++ b/selectors.py	Thu May 20 20:50:00 2010 +0200
@@ -1033,7 +1033,7 @@
         return self.score(req, rset, row, col)
 
     def score_entity(self, entity):
-        if entity.has_perm(self.action):
+        if entity.cw_has_perm(self.action):
             return 1
         return 0
 
--- a/server/repository.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/repository.py	Thu May 20 20:50:00 2010 +0200
@@ -565,7 +565,7 @@
             session.close()
         session = Session(user, self, cnxprops)
         user._cw = user.cw_rset.req = session
-        user.clear_related_cache()
+        user.cw_clear_relation_cache()
         self._sessions[session.id] = session
         self.info('opened %s', session)
         self.hm.call_hooks('session_open', session)
@@ -1021,17 +1021,12 @@
         the entity instance
         """
         # init edited_attributes before calling before_add_entity hooks
-        entity._is_saved = False # entity has an eid but is not yet saved
-        entity.edited_attributes = set(entity)
-        entity_ = entity.pre_add_hook()
-        # XXX kill that transmutation feature !
-        if not entity_ is entity:
-            entity.__class__ = entity_.__class__
-            entity.__dict__.update(entity_.__dict__)
+        entity._cw_is_saved = False # entity has an eid but is not yet saved
+        entity.edited_attributes = set(entity) # XXX cw_edited_attributes
         eschema = entity.e_schema
         source = self.locate_etype_source(entity.__regid__)
         # allocate an eid to the entity before calling hooks
-        entity.set_eid(self.system_source.create_eid(session))
+        entity.eid = self.system_source.create_eid(session)
         # set caches asap
         extid = self.init_entity_caches(session, entity, source)
         if server.DEBUG & server.DBG_REPO:
@@ -1046,12 +1041,12 @@
             rschema = eschema.subjrels[attr]
             if not rschema.final: # inlined relation
                 relations.append((attr, entity[attr]))
-        entity.set_defaults()
+        entity._cw_set_defaults()
         if session.is_hook_category_activated('integrity'):
-            entity.check(creation=True)
+            entity._cw_check(creation=True)
         source.add_entity(session, entity)
         self.add_info(session, entity, source, extid, complete=False)
-        entity._is_saved = True # entity has an eid and is saved
+        entity._cw_is_saved = True # entity has an eid and is saved
         # prefill entity relation caches
         for rschema in eschema.subject_relations():
             rtype = str(rschema)
@@ -1060,12 +1055,13 @@
             if rschema.final:
                 entity.setdefault(rtype, None)
             else:
-                entity.set_related_cache(rtype, 'subject', session.empty_rset())
+                entity.cw_set_relation_cache(rtype, 'subject',
+                                             session.empty_rset())
         for rschema in eschema.object_relations():
             rtype = str(rschema)
             if rtype in schema.VIRTUAL_RTYPES:
                 continue
-            entity.set_related_cache(rtype, 'object', session.empty_rset())
+            entity.cw_set_relation_cache(rtype, 'object', session.empty_rset())
         # set inline relation cache before call to after_add_entity
         for attr, value in relations:
             session.update_rel_cache_add(entity.eid, attr, value)
@@ -1094,7 +1090,7 @@
         entity.edited_attributes = edited_attributes
         try:
             if session.is_hook_category_activated('integrity'):
-                entity.check()
+                entity._cw_check()
             only_inline_rels, need_fti_update = True, False
             relations = []
             source = self.source_from_eid(entity.eid, session)
@@ -1132,7 +1128,7 @@
                     hm.call_hooks('after_update_entity', session, entity=entity)
                 for attr, value, prevvalue in relations:
                     # if the relation is already cached, update existant cache
-                    relcache = entity.relation_cached(attr, 'subject')
+                    relcache = entity.cw_relation_cached(attr, 'subject')
                     if prevvalue is not None:
                         hm.call_hooks('after_delete_relation', session,
                                       eidfrom=entity.eid, rtype=attr, eidto=prevvalue)
@@ -1142,8 +1138,8 @@
                     if relcache is not None:
                         session.update_rel_cache_add(entity.eid, attr, value)
                     else:
-                        entity.set_related_cache(attr, 'subject',
-                                                 session.eid_rset(value))
+                        entity.cw_set_relation_cache(attr, 'subject',
+                                                     session.eid_rset(value))
                     hm.call_hooks('after_add_relation', session,
                                   eidfrom=entity.eid, rtype=attr, eidto=value)
         finally:
--- a/server/session.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/session.py	Thu May 20 20:50:00 2010 +0200
@@ -242,7 +242,7 @@
             entity = self.entity_cache(eid)
         except KeyError:
             return
-        rcache = entity.relation_cached(rtype, role)
+        rcache = entity.cw_relation_cached(rtype, role)
         if rcache is not None:
             rset, entities = rcache
             rset = rset.copy()
@@ -258,14 +258,15 @@
                 targetentity.cw_col = 0
             rset.rowcount += 1
             entities.append(targetentity)
-            entity._related_cache['%s_%s' % (rtype, role)] = (rset, tuple(entities))
+            entity._cw_related_cache['%s_%s' % (rtype, role)] = (
+                rset, tuple(entities))
 
     def _update_entity_rel_cache_del(self, eid, rtype, role, targeteid):
         try:
             entity = self.entity_cache(eid)
         except KeyError:
             return
-        rcache = entity.relation_cached(rtype, role)
+        rcache = entity.cw_relation_cached(rtype, role)
         if rcache is not None:
             rset, entities = rcache
             for idx, row in enumerate(rset.rows):
@@ -284,7 +285,8 @@
                 del rset.description[idx]
             del entities[idx]
             rset.rowcount -= 1
-            entity._related_cache['%s_%s' % (rtype, role)] = (rset, tuple(entities))
+            entity._cw_related_cache['%s_%s' % (rtype, role)] = (
+                rset, tuple(entities))
 
     # resource accessors ######################################################
 
--- a/server/sources/__init__.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/sources/__init__.py	Thu May 20 20:50:00 2010 +0200
@@ -341,7 +341,7 @@
         entity.
         """
         entity = self.repo.vreg['etypes'].etype_class(etype)(session)
-        entity.set_eid(eid)
+        entity.eid = eid
         return entity
 
     def after_entity_insertion(self, session, lid, entity):
--- a/server/sources/native.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/sources/native.py	Thu May 20 20:50:00 2010 +0200
@@ -1007,10 +1007,10 @@
                 entity[rtype] = unicode(value, session.encoding, 'replace')
             else:
                 entity[rtype] = value
-        entity.set_eid(eid)
+        entity.eid = eid
         session.repo.init_entity_caches(session, entity, self)
         entity.edited_attributes = set(entity)
-        entity.check()
+        entity._cw_check()
         self.repo.hm.call_hooks('before_add_entity', session, entity=entity)
         # restore the entity
         action.changes['cw_eid'] = eid
@@ -1077,7 +1077,7 @@
             return [session._(
                 "Can't undo creation of entity %(eid)s of type %(etype)s, type "
                 "no more supported" % {'eid': eid, 'etype': etype})]
-        entity.set_eid(eid)
+        entity.eid = eid
         # for proper eid/type cache update
         hook.set_operation(session, 'pendingeids', eid,
                            CleanupDeletedEidsCacheOp)
--- a/server/ssplanner.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/ssplanner.py	Thu May 20 20:50:00 2010 +0200
@@ -487,7 +487,7 @@
                     value = row[index]
                     index += 1
                 if rorder == InsertRelationsStep.FINAL:
-                    edef.rql_set_value(rtype, value)
+                    edef._cw_rql_set_value(rtype, value)
                 elif rorder == InsertRelationsStep.RELATION:
                     self.plan.add_relation_def( (edef, rtype, value) )
                     edef.querier_pending_relations[(rtype, 'subject')] = value
@@ -584,7 +584,7 @@
                         edef = edefs[eid]
                     except KeyError:
                         edefs[eid] = edef = session.entity_from_eid(eid)
-                    edef.rql_set_value(str(rschema), rhsval)
+                    edef._cw_rql_set_value(str(rschema), rhsval)
                 else:
                     repo.glob_add_relation(session, lhsval, str(rschema), rhsval)
             result[i] = newrow
--- a/server/test/unittest_multisources.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/test/unittest_multisources.py	Thu May 20 20:50:00 2010 +0200
@@ -15,9 +15,6 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""
-
-"""
 from os.path import dirname, join, abspath
 from datetime import datetime, timedelta
 
@@ -113,11 +110,11 @@
         self.assertEquals(len(rset), 4)
         # since they are orderd by eid, we know the 3 first one is coming from the system source
         # and the others from external source
-        self.assertEquals(rset.get_entity(0, 0).metainformation(),
+        self.assertEquals(rset.get_entity(0, 0).cw_metainformation(),
                           {'source': {'adapter': 'native', 'uri': 'system'},
                            'type': u'Card', 'extid': None})
         externent = rset.get_entity(3, 0)
-        metainf = externent.metainformation()
+        metainf = externent.cw_metainformation()
         self.assertEquals(metainf['source'], {'adapter': 'pyrorql', 'base-url': 'http://extern.org/', 'uri': 'extern'})
         self.assertEquals(metainf['type'], 'Card')
         self.assert_(metainf['extid'])
--- a/server/test/unittest_security.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/test/unittest_security.py	Thu May 20 20:50:00 2010 +0200
@@ -192,8 +192,7 @@
         self.assertEquals(len(rset), 1)
         ent = rset.get_entity(0, 0)
         session.set_pool() # necessary
-        self.assertRaises(Unauthorized,
-                          ent.e_schema.check_perm, session, 'update', eid=ent.eid)
+        self.assertRaises(Unauthorized, ent.cw_check_perm, 'update')
         self.assertRaises(Unauthorized,
                           cu.execute, "SET P travaille S WHERE P is Personne, S is Societe")
         # test nothing has actually been inserted:
@@ -561,11 +560,11 @@
         self.execute('SET TI comment %(c)s WHERE TI wf_info_for X, X ref "ARCT01"',
                      {'c': u'bouh!'})
         self.commit()
-        aff.clear_related_cache('wf_info_for', 'object')
+        aff.cw_clear_relation_cache('wf_info_for', 'object')
         trinfo = iworkflowable.latest_trinfo()
         self.assertEquals(trinfo.comment, 'bouh!')
         # but not from_state/to_state
-        aff.clear_related_cache('wf_info_for', role='object')
+        aff.cw_clear_relation_cache('wf_info_for', role='object')
         self.assertRaises(Unauthorized,
                           self.execute, 'SET TI from_state S WHERE TI eid %(ti)s, S name "ben non"',
                           {'ti': trinfo.eid})
--- a/server/test/unittest_storage.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/test/unittest_storage.py	Thu May 20 20:50:00 2010 +0200
@@ -15,9 +15,7 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""unit tests for module cubicweb.server.sources.storages
-
-"""
+"""unit tests for module cubicweb.server.sources.storages"""
 
 from __future__ import with_statement
 
@@ -89,11 +87,11 @@
         f1.set_attributes(data=Binary('the new data'))
         self.rollback()
         self.assertEquals(file(expected_filepath).read(), 'the-data')
-        f1.delete()
+        f1.cw_delete()
         self.failUnless(osp.isfile(expected_filepath))
         self.rollback()
         self.failUnless(osp.isfile(expected_filepath))
-        f1.delete()
+        f1.cw_delete()
         self.commit()
         self.failIf(osp.isfile(expected_filepath))
 
--- a/server/test/unittest_undo.py	Thu May 20 20:47:55 2010 +0200
+++ b/server/test/unittest_undo.py	Thu May 20 20:50:00 2010 +0200
@@ -15,9 +15,6 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""
-
-"""
 from __future__ import with_statement
 
 from cubicweb import ValidationError
@@ -104,7 +101,7 @@
                                        address=u'toto@logilab.org',
                                        reverse_use_email=toto)
         txuuid1 = self.commit()
-        toto.delete()
+        toto.cw_delete()
         txuuid2 = self.commit()
         undoable_transactions = self.cnx.undoable_transactions
         txs = undoable_transactions(action='D')
@@ -147,7 +144,7 @@
         self.commit()
         txs = self.cnx.undoable_transactions()
         self.assertEquals(len(txs), 2)
-        toto.delete()
+        toto.cw_delete()
         txuuid = self.commit()
         actions = self.cnx.transaction_info(txuuid).actions_list()
         self.assertEquals(len(actions), 1)
@@ -186,7 +183,7 @@
         c = session.create_entity('Card', title=u'hop', content=u'hop')
         p = session.create_entity('Personne', nom=u'louis', fiche=c)
         self.commit()
-        c.delete()
+        c.cw_delete()
         txuuid = self.commit()
         c2 = session.create_entity('Card', title=u'hip', content=u'hip')
         p.set_relations(fiche=c2)
@@ -207,9 +204,9 @@
         session.execute('DELETE U in_group G WHERE U eid %(x)s', {'x': self.toto.eid})
         self.toto.set_relations(in_group=g)
         self.commit()
-        self.toto.delete()
+        self.toto.cw_delete()
         txuuid = self.commit()
-        g.delete()
+        g.cw_delete()
         self.commit()
         errors = self.cnx.undo_transaction(txuuid)
         self.assertEquals(errors,
--- a/test/unittest_entity.py	Thu May 20 20:47:55 2010 +0200
+++ b/test/unittest_entity.py	Thu May 20 20:50:00 2010 +0200
@@ -103,21 +103,21 @@
         e = self.execute('Any X WHERE X eid %(x)s', {'x': eid2}).get_entity(0, 0)
         e.copy_relations(user.eid)
         self.commit()
-        e.clear_related_cache('in_state', 'subject')
+        e.cw_clear_relation_cache('in_state', 'subject')
         self.assertEquals(e.cw_adapt_to('IWorkflowable').state, 'activated')
 
     def test_related_cache_both(self):
         user = self.execute('Any X WHERE X eid %(x)s', {'x':self.user().eid}).get_entity(0, 0)
         adeleid = self.execute('INSERT EmailAddress X: X address "toto@logilab.org", U use_email X WHERE U login "admin"')[0][0]
         self.commit()
-        self.assertEquals(user._related_cache, {})
+        self.assertEquals(user._cw_related_cache, {})
         email = user.primary_email[0]
-        self.assertEquals(sorted(user._related_cache), ['primary_email_subject'])
-        self.assertEquals(email._related_cache.keys(), ['primary_email_object'])
+        self.assertEquals(sorted(user._cw_related_cache), ['primary_email_subject'])
+        self.assertEquals(email._cw_related_cache.keys(), ['primary_email_object'])
         groups = user.in_group
-        self.assertEquals(sorted(user._related_cache), ['in_group_subject', 'primary_email_subject'])
+        self.assertEquals(sorted(user._cw_related_cache), ['in_group_subject', 'primary_email_subject'])
         for group in groups:
-            self.failIf('in_group_subject' in group._related_cache, group._related_cache.keys())
+            self.failIf('in_group_subject' in group._cw_related_cache, group._cw_related_cache.keys())
 
     def test_related_limit(self):
         req = self.request()
@@ -197,20 +197,20 @@
         Note.fetch_attrs, Note.fetch_order = fetch_config(('type',))
         SubNote.fetch_attrs, SubNote.fetch_order = fetch_config(('type',))
         p = self.request().create_entity('Personne', nom=u'pouet')
-        self.assertEquals(p.related_rql('evaluee'),
+        self.assertEquals(p.cw_related_rql('evaluee'),
                           'Any X,AA,AB ORDERBY AA ASC WHERE E eid %(x)s, E evaluee X, '
                           'X type AA, X modification_date AB')
         Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', ))
         # XXX
-        self.assertEquals(p.related_rql('evaluee'),
+        self.assertEquals(p.cw_related_rql('evaluee'),
                           'Any X,AA ORDERBY AA DESC '
                           'WHERE E eid %(x)s, E evaluee X, X modification_date AA')
 
         tag = self.vreg['etypes'].etype_class('Tag')(self.request())
-        self.assertEquals(tag.related_rql('tags', 'subject'),
+        self.assertEquals(tag.cw_related_rql('tags', 'subject'),
                           'Any X,AA ORDERBY AA DESC '
                           'WHERE E eid %(x)s, E tags X, X modification_date AA')
-        self.assertEquals(tag.related_rql('tags', 'subject', ('Personne',)),
+        self.assertEquals(tag.cw_related_rql('tags', 'subject', ('Personne',)),
                           'Any X,AA,AB ORDERBY AA ASC '
                           'WHERE E eid %(x)s, E tags X, X is IN (Personne), X nom AA, '
                           'X modification_date AB')
@@ -219,47 +219,47 @@
         tag = self.vreg['etypes'].etype_class('Tag')(self.request())
         for ttype in self.schema['tags'].objects():
             self.vreg['etypes'].etype_class(ttype).fetch_attrs = ('modification_date',)
-        self.assertEquals(tag.related_rql('tags', 'subject'),
+        self.assertEquals(tag.cw_related_rql('tags', 'subject'),
                           'Any X,AA ORDERBY AA DESC '
                           'WHERE E eid %(x)s, E tags X, X modification_date AA')
 
     def test_unrelated_rql_security_1(self):
         user = self.request().user
-        rql = user.unrelated_rql('use_email', 'EmailAddress', 'subject')[0]
+        rql = user.cw_unrelated_rql('use_email', 'EmailAddress', 'subject')[0]
         self.assertEquals(rql, 'Any O,AA,AB,AC ORDERBY AC DESC '
                           'WHERE NOT S use_email O, S eid %(x)s, O is EmailAddress, O address AA, O alias AB, O modification_date AC')
         self.create_user('toto')
         self.login('toto')
         user = self.request().user
-        rql = user.unrelated_rql('use_email', 'EmailAddress', 'subject')[0]
+        rql = user.cw_unrelated_rql('use_email', 'EmailAddress', 'subject')[0]
         self.assertEquals(rql, 'Any O,AA,AB,AC ORDERBY AC DESC '
                           'WHERE NOT S use_email O, S eid %(x)s, O is EmailAddress, O address AA, O alias AB, O modification_date AC')
         user = self.execute('Any X WHERE X login "admin"').get_entity(0, 0)
-        self.assertRaises(Unauthorized, user.unrelated_rql, 'use_email', 'EmailAddress', 'subject')
+        self.assertRaises(Unauthorized, user.cw_unrelated_rql, 'use_email', 'EmailAddress', 'subject')
         self.login('anon')
         user = self.request().user
-        self.assertRaises(Unauthorized, user.unrelated_rql, 'use_email', 'EmailAddress', 'subject')
+        self.assertRaises(Unauthorized, user.cw_unrelated_rql, 'use_email', 'EmailAddress', 'subject')
 
     def test_unrelated_rql_security_2(self):
         email = self.execute('INSERT EmailAddress X: X address "hop"').get_entity(0, 0)
-        rql = email.unrelated_rql('use_email', 'CWUser', 'object')[0]
+        rql = email.cw_unrelated_rql('use_email', 'CWUser', 'object')[0]
         self.assertEquals(rql, 'Any S,AA,AB,AC,AD ORDERBY AA ASC '
                           'WHERE NOT S use_email O, O eid %(x)s, S is CWUser, S login AA, S firstname AB, S surname AC, S modification_date AD')
-        #rql = email.unrelated_rql('use_email', 'Person', 'object')[0]
+        #rql = email.cw_unrelated_rql('use_email', 'Person', 'object')[0]
         #self.assertEquals(rql, '')
         self.login('anon')
         email = self.execute('Any X WHERE X eid %(x)s', {'x': email.eid}).get_entity(0, 0)
-        rql = email.unrelated_rql('use_email', 'CWUser', 'object')[0]
+        rql = email.cw_unrelated_rql('use_email', 'CWUser', 'object')[0]
         self.assertEquals(rql, 'Any S,AA,AB,AC,AD ORDERBY AA '
                           'WHERE NOT S use_email O, O eid %(x)s, S is CWUser, S login AA, S firstname AB, S surname AC, S modification_date AD, '
                           'A eid %(B)s, EXISTS(S identity A, NOT A in_group C, C name "guests", C is CWGroup)')
-        #rql = email.unrelated_rql('use_email', 'Person', 'object')[0]
+        #rql = email.cw_unrelated_rql('use_email', 'Person', 'object')[0]
         #self.assertEquals(rql, '')
 
     def test_unrelated_rql_security_nonexistant(self):
         self.login('anon')
         email = self.vreg['etypes'].etype_class('EmailAddress')(self.request())
-        rql = email.unrelated_rql('use_email', 'CWUser', 'object')[0]
+        rql = email.cw_unrelated_rql('use_email', 'CWUser', 'object')[0]
         self.assertEquals(rql, 'Any S,AA,AB,AC,AD ORDERBY AA '
                           'WHERE S is CWUser, S login AA, S firstname AB, S surname AC, S modification_date AD, '
                           'A eid %(B)s, EXISTS(S identity A, NOT A in_group C, C name "guests", C is CWGroup)')
@@ -455,9 +455,9 @@
         trinfo = self.execute('Any X WHERE X eid %(x)s', {'x': eid}).get_entity(0, 0)
         trinfo.complete()
         self.failUnless(isinstance(trinfo['creation_date'], datetime))
-        self.failUnless(trinfo.relation_cached('from_state', 'subject'))
-        self.failUnless(trinfo.relation_cached('to_state', 'subject'))
-        self.failUnless(trinfo.relation_cached('wf_info_for', 'subject'))
+        self.failUnless(trinfo.cw_relation_cached('from_state', 'subject'))
+        self.failUnless(trinfo.cw_relation_cached('to_state', 'subject'))
+        self.failUnless(trinfo.cw_relation_cached('wf_info_for', 'subject'))
         self.assertEquals(trinfo.by_transition, ())
 
     def test_request_cache(self):
@@ -501,7 +501,7 @@
     def test_metainformation_and_external_absolute_url(self):
         req = self.request()
         note = req.create_entity('Note', type=u'z')
-        metainf = note.metainformation()
+        metainf = note.cw_metainformation()
         self.assertEquals(metainf, {'source': {'adapter': 'native', 'uri': 'system'}, 'type': u'Note', 'extid': None})
         self.assertEquals(note.absolute_url(), 'http://testing.fr/cubicweb/note/%s' % note.eid)
         metainf['source'] = metainf['source'].copy()
--- a/test/unittest_rset.py	Thu May 20 20:47:55 2010 +0200
+++ b/test/unittest_rset.py	Thu May 20 20:50:00 2010 +0200
@@ -229,10 +229,10 @@
         self.assertEquals(e['surname'], 'di mascio')
         self.assertRaises(KeyError, e.__getitem__, 'firstname')
         self.assertRaises(KeyError, e.__getitem__, 'creation_date')
-        self.assertEquals(pprelcachedict(e._related_cache), [])
+        self.assertEquals(pprelcachedict(e._cw_related_cache), [])
         e.complete()
         self.assertEquals(e['firstname'], 'adrien')
-        self.assertEquals(pprelcachedict(e._related_cache), [])
+        self.assertEquals(pprelcachedict(e._cw_related_cache), [])
 
     def test_get_entity_advanced(self):
         self.request().create_entity('Bookmark', title=u'zou', path=u'/view')
@@ -245,19 +245,19 @@
         self.assertEquals(e['title'], 'zou')
         self.assertRaises(KeyError, e.__getitem__, 'path')
         self.assertEquals(e.view('text'), 'zou')
-        self.assertEquals(pprelcachedict(e._related_cache), [])
+        self.assertEquals(pprelcachedict(e._cw_related_cache), [])
 
         e = rset.get_entity(0, 1)
         self.assertEquals(e.cw_row, 0)
         self.assertEquals(e.cw_col, 1)
         self.assertEquals(e['login'], 'anon')
         self.assertRaises(KeyError, e.__getitem__, 'firstname')
-        self.assertEquals(pprelcachedict(e._related_cache),
+        self.assertEquals(pprelcachedict(e._cw_related_cache),
                           [])
         e.complete()
         self.assertEquals(e['firstname'], None)
         self.assertEquals(e.view('text'), 'anon')
-        self.assertEquals(pprelcachedict(e._related_cache),
+        self.assertEquals(pprelcachedict(e._cw_related_cache),
                           [])
 
         self.assertRaises(NotAnEntity, rset.get_entity, 0, 2)
@@ -269,7 +269,7 @@
         seid = self.execute('State X WHERE X name "activated"')[0][0]
         # for_user / in_group are prefetched in CWUser __init__, in_state should
         # be filed from our query rset
-        self.assertEquals(pprelcachedict(e._related_cache),
+        self.assertEquals(pprelcachedict(e._cw_related_cache),
                           [('in_state_subject', [seid])])
 
     def test_get_entity_advanced_prefilled_cache(self):
@@ -279,7 +279,7 @@
                             'X title XT, S name SN, U login UL, X eid %s' % e.eid)
         e = rset.get_entity(0, 0)
         self.assertEquals(e['title'], 'zou')
-        self.assertEquals(pprelcachedict(e._related_cache),
+        self.assertEquals(pprelcachedict(e._cw_related_cache),
                           [('created_by_subject', [5])])
         # first level of recursion
         u = e.created_by[0]
@@ -298,9 +298,9 @@
         e = rset.get_entity(0, 0)
         # if any of the assertion below fails with a KeyError, the relation is not cached
         # related entities should be an empty list
-        self.assertEquals(e.related_cache('primary_email', 'subject', True), ())
+        self.assertEquals(e._cw_relation_cache('primary_email', 'subject', True), ())
         # related rset should be an empty rset
-        cached = e.related_cache('primary_email', 'subject', False)
+        cached = e._cw_relation_cache('primary_email', 'subject', False)
         self.assertIsInstance(cached, ResultSet)
         self.assertEquals(cached.rowcount, 0)
 
--- a/web/formfields.py	Thu May 20 20:47:55 2010 +0200
+++ b/web/formfields.py	Thu May 20 20:50:00 2010 +0200
@@ -323,7 +323,7 @@
                     value = getattr(entity, self.name)
                     if value is not None or not self.fallback_on_none_attribute:
                         return value
-            elif entity.has_eid() or entity.relation_cached(self.name, self.role):
+            elif entity.has_eid() or entity.cw_relation_cached(self.name, self.role):
                 value = [r[0] for r in entity.related(self.name, self.role)]
                 if value or not self.fallback_on_none_attribute:
                     return value
@@ -399,7 +399,7 @@
             entity = form.edited_entity
             if entity.e_schema.has_metadata(self.name, 'format') and (
                 entity.has_eid() or '%s_format' % self.name in entity):
-                return form.edited_entity.attr_metadata(self.name, 'format')
+                return form.edited_entity.cw_attr_metadata(self.name, 'format')
         return form._cw.property_value('ui.default-text-format')
 
     def encoding(self, form):
@@ -408,7 +408,7 @@
             entity = form.edited_entity
             if entity.e_schema.has_metadata(self.name, 'encoding') and (
                 entity.has_eid() or '%s_encoding' % self.name in entity):
-                return form.edited_entity.attr_metadata(self.name, 'encoding')
+                return form.edited_entity.cw_attr_metadata(self.name, 'encoding')
         return form._cw.encoding
 
     def form_init(self, form):
--- a/web/views/autoform.py	Thu May 20 20:47:55 2010 +0200
+++ b/web/views/autoform.py	Thu May 20 20:50:00 2010 +0200
@@ -766,7 +766,7 @@
         """return a list of (relation schema, role) to edit for the entity"""
         if self.display_fields is not None:
             return self.display_fields
-        if self.edited_entity.has_eid() and not self.edited_entity.has_perm('update'):
+        if self.edited_entity.has_eid() and not self.edited_entity.cw_has_perm('update'):
             return []
         # XXX we should simply put eid in the generated section, no?
         return [(rtype, role) for rtype, _, role in self._relations_by_section(
@@ -869,7 +869,7 @@
             vvreg = self._cw.vreg['views']
             # display inline-edition view for all existing related entities
             for i, relentity in enumerate(related.entities()):
-                if relentity.has_perm('update'):
+                if relentity.cw_has_perm('update'):
                     yield vvreg.select('inline-edition', self._cw,
                                        rset=related, row=i, col=0,
                                        etype=ttype, rtype=rschema, role=role,
--- a/web/views/editcontroller.py	Thu May 20 20:47:55 2010 +0200
+++ b/web/views/editcontroller.py	Thu May 20 20:50:00 2010 +0200
@@ -305,7 +305,7 @@
             entity = self._cw.entity_from_eid(eid, etype)
             path, params = entity.cw_adapt_to('IEditControl').after_deletion_path()
             redirect_info.add( (path, tuple(params.iteritems())) )
-            entity.delete()
+            entity.cw_delete()
         if len(redirect_info) > 1:
             # In the face of ambiguity, refuse the temptation to guess.
             self._after_deletion_path = 'view', ()
--- a/web/views/editforms.py	Thu May 20 20:47:55 2010 +0200
+++ b/web/views/editforms.py	Thu May 20 20:50:00 2010 +0200
@@ -206,7 +206,7 @@
             if not rschema.final:
                 # ensure relation cache is filed
                 rset = self.copying.related(rschema, role)
-                self.newentity.set_related_cache(rschema, role, rset)
+                self.newentity.cw_set_relation_cache(rschema, role, rset)
 
     def submited_message(self):
         """return the message that will be displayed on successful edition"""
@@ -342,7 +342,7 @@
         rdef = entity.e_schema.rdef(rtype)
         afs = uicfg.autoform_section.etype_get(
             entity.__regid__, rtype, 'subject', rdef.object)
-        if 'main_hidden' in afs or not entity.has_perm('update'):
+        if 'main_hidden' in afs or not entity.cw_has_perm('update'):
             return False
         if not rdef.has_perm(self._cw, 'update', eid=entity.eid):
             return False
--- a/web/views/editviews.py	Thu May 20 20:47:55 2010 +0200
+++ b/web/views/editviews.py	Thu May 20 20:50:00 2010 +0200
@@ -59,9 +59,9 @@
         # them. Use fetch_order and not fetch_unrelated_order as sort method
         # since the latter is mainly there to select relevant items in the combo
         # box, it doesn't give interesting result in this context
-        rql, args = entity.unrelated_rql(rtype, etype, role,
-                                         ordermethod='fetch_order',
-                                         vocabconstraints=False)
+        rql, args = entity.cw_unrelated_rql(rtype, etype, role,
+                                            ordermethod='fetch_order',
+                                            vocabconstraints=False)
         rset = self._cw.execute(rql, args, tuple(args))
         return rset, 'list', "search-associate-content", True
 
--- a/web/views/treeview.py	Thu May 20 20:47:55 2010 +0200
+++ b/web/views/treeview.py	Thu May 20 20:50:00 2010 +0200
@@ -54,7 +54,7 @@
 
         XXX should be removed from the public interface
         """
-        return self.entity.related_rql(self.tree_relation, self.parent_role)
+        return self.entity.cw_related_rql(self.tree_relation, self.parent_role)
 
     @implements_adapter_compat('ITree')
     def different_type_children(self, entities=True):