# HG changeset patch # User Sylvain Thénault # Date 1316700748 -7200 # Node ID 749e1a67987f6ba4f5c7e31477874e0fb30ecc0b # Parent 9bbf83f68bcc080256ca80385b20eab12631d3b0 [entity] rename Entity._rest_attr_info into cw_rest_attr_info (closes #1942759) diff -r 9bbf83f68bcc -r 749e1a67987f doc/3.14.rst --- a/doc/3.14.rst Thu Sep 22 16:12:23 2011 +0200 +++ b/doc/3.14.rst Thu Sep 22 16:12:28 2011 +0200 @@ -23,3 +23,9 @@ - client code use direct access to one of those methods on an entity (no code known to do that) +* `Entity._rest_attr_info` class method has been renamed to + `Entity.cw_rest_attr_info` + + No backward compat yet since this is a protected method an no code is known to + use it outside cubicweb itself. + diff -r 9bbf83f68bcc -r 749e1a67987f entity.py --- a/entity.py Thu Sep 22 16:12:23 2011 +0200 +++ b/entity.py Thu Sep 22 16:12:28 2011 +0200 @@ -345,14 +345,25 @@ @classmethod @cached - def _rest_attr_info(cls): + def cw_rest_attr_info(cls): + """this class method return an attribute name to be used in URL for + entities of this type and a boolean flag telling if its value should be + checked for uniqness. + + The attribute returned is, in order of priority: + + * class's `rest_attr` class attribute + * an attribute defined as unique in the class'schema + * 'eid' + """ mainattr, needcheck = 'eid', True if cls.rest_attr: mainattr = cls.rest_attr needcheck = not cls.e_schema.has_unique_values(mainattr) else: for rschema in cls.e_schema.subject_relations(): - if rschema.final and rschema != 'eid' and cls.e_schema.has_unique_values(rschema): + if rschema.final and rschema != 'eid' \ + and cls.e_schema.has_unique_values(rschema): mainattr = str(rschema) needcheck = False break @@ -544,7 +555,7 @@ 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() + mainattr, needcheck = self.cw_rest_attr_info() etype = str(self.e_schema) path = etype.lower() if mainattr != 'eid': diff -r 9bbf83f68bcc -r 749e1a67987f web/views/urlpublishing.py --- a/web/views/urlpublishing.py Thu Sep 22 16:12:23 2011 +0200 +++ b/web/views/urlpublishing.py Thu Sep 22 16:12:28 2011 +0200 @@ -174,7 +174,7 @@ except KeyError: raise PathDontMatch() else: - attrname = cls._rest_attr_info()[0] + attrname = cls.cw_rest_attr_info()[0] value = req.url_unquote(parts.pop(0)) return self.handle_etype_attr(req, cls, attrname, value) return self.handle_etype(req, cls)