[AnyEntity] rename __linkto attribute as cw_linkto to avoid name mangling which make overriding/monkey-patching unnecessarily harder stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 30 Mar 2011 14:03:10 +0200
branchstable
changeset 7143 0517e3bf0b84
parent 7142 c47381851a3e
child 7144 7c9bfd4f4933
[AnyEntity] rename __linkto attribute as cw_linkto to avoid name mangling which make overriding/monkey-patching unnecessarily harder
entities/__init__.py
--- a/entities/__init__.py	Wed Mar 30 13:59:23 2011 +0200
+++ b/entities/__init__.py	Wed Mar 30 14:03:10 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -121,16 +121,18 @@
     # edition helper functions ################################################
 
     def linked_to(self, rtype, role, remove=True):
-        """if entity should be linked to another using __linkto form param for
+        """if entity should be linked to another using '__linkto' form param for
         the given relation/role, return eids of related entities
 
         This method is consuming matching link-to information from form params
-        if `remove` is True (by default).
+        if `remove` is True (by default). Computed values are stored into a
+        `cw_linkto` attribute, a dictionary with (relation, role) as key and
+        linked eids as value.
         """
         try:
-            return self.__linkto[(rtype, role)]
+            return self.cw_linkto[(rtype, role)]
         except AttributeError:
-            self.__linkto = {}
+            self.cw_linkto = {}
         except KeyError:
             pass
         linktos = list(self._cw.list_form_param('__linkto'))
@@ -144,7 +146,7 @@
                     linktos.remove(linkto)
                     self._cw.form['__linkto'] = linktos
                 linkedto.append(typed_eid(eid))
-        self.__linkto[(rtype, role)] = linkedto
+        self.cw_linkto[(rtype, role)] = linkedto
         return linkedto
 
     # server side helpers #####################################################