# HG changeset patch # User Sylvain Thénault # Date 1274447069 -7200 # Node ID cb14af012a963f88e0dd1c7b66f75d333799009d # Parent 83acff1b50cc0ecdbb6dd1fb609bf82f35850b76 [adapters] refactoring fixes diff -r 83acff1b50cc -r cb14af012a96 mixins.py --- a/mixins.py Fri May 21 15:02:56 2010 +0200 +++ b/mixins.py Fri May 21 15:04:29 2010 +0200 @@ -186,6 +186,21 @@ } +# XXX move to cubicweb.web.views.treeview once we delete usage from this file +def _done_init(done, view, row, col): + """handle an infinite recursion safety belt""" + if done is None: + done = set() + entity = view.cw_rset.get_entity(row, col) + if entity.eid in done: + msg = entity._cw._('loop in %(rel)s relation (%(eid)s)') % { + 'rel': entity.tree_attribute, + 'eid': entity.eid + } + return None, msg + done.add(entity.eid) + return done, entity + class TreeViewMixIn(object): """a recursive tree view""" diff -r 83acff1b50cc -r cb14af012a96 vregistry.py --- a/vregistry.py Fri May 21 15:02:56 2010 +0200 +++ b/vregistry.py Fri May 21 15:04:29 2010 +0200 @@ -45,7 +45,7 @@ from cubicweb import CW_SOFTWARE_ROOT from cubicweb import RegistryNotFound, ObjectNotFound, NoSelectableObject -from cubicweb.appobject import AppObject +from cubicweb.appobject import AppObject, class_regid def _toload_info(path, extrapath, _toload=None): """return a dictionary of : and an ordered list of @@ -84,16 +84,6 @@ """returns a unique identifier for an appobject class""" return '%s.%s' % (cls.__module__, cls.__name__) -def class_regid(cls): - """returns a unique identifier for an appobject class""" - if 'id' in cls.__dict__: - warn('[3.6] %s.%s: id is deprecated, use __regid__' - % (cls.__module__, cls.__name__), DeprecationWarning) - cls.__regid__ = cls.id - if hasattr(cls, 'id') and not isinstance(cls.id, property): - return cls.id - return cls.__regid__ - def class_registries(cls, registryname): if registryname: return (registryname,) diff -r 83acff1b50cc -r cb14af012a96 web/test/unittest_breadcrumbs.py --- a/web/test/unittest_breadcrumbs.py Fri May 21 15:02:56 2010 +0200 +++ b/web/test/unittest_breadcrumbs.py Fri May 21 15:04:29 2010 +0200 @@ -15,8 +15,10 @@ # # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . + from cubicweb.devtools.testlib import CubicWebTC + class BreadCrumbsTC(CubicWebTC): def test_base(self): diff -r 83acff1b50cc -r cb14af012a96 web/views/editcontroller.py --- a/web/views/editcontroller.py Fri May 21 15:02:56 2010 +0200 +++ b/web/views/editcontroller.py Fri May 21 15:04:29 2010 +0200 @@ -42,10 +42,10 @@ """return (path, parameters) which should be used as redirect information when this entity is being deleted """ - parent = self.cw_adapt_to('IBreadCrumbs').parent_entity() + parent = self.entity.cw_adapt_to('IBreadCrumbs').parent_entity() if parent is not None: return parent.rest_path(), {} - return str(self.e_schema).lower(), {} + return str(self.entity.e_schema).lower(), {} @implements_adapter_compat('IEditControl') def pre_web_edit(self): diff -r 83acff1b50cc -r cb14af012a96 web/views/emailaddress.py --- a/web/views/emailaddress.py Fri May 21 15:02:56 2010 +0200 +++ b/web/views/emailaddress.py Fri May 21 15:04:29 2010 +0200 @@ -144,4 +144,4 @@ __select__ = implements('EmailAddress') def parent_entity(self): - return self.email_of + return self.entity.email_of diff -r 83acff1b50cc -r cb14af012a96 web/views/ibreadcrumbs.py --- a/web/views/ibreadcrumbs.py Fri May 21 15:02:56 2010 +0200 +++ b/web/views/ibreadcrumbs.py Fri May 21 15:04:29 2010 +0200 @@ -75,11 +75,12 @@ to displayed view (may be None). When recursing on a parent entity, the `recurs` argument should be set to True. """ - path = [self.entity] parent = self.parent_entity() if parent is not None: - adapter = ibreadcrumb_adapter(self.entity) + adapter = ibreadcrumb_adapter(parent) path = adapter.breadcrumbs(view, True) + [self.entity] + else: + path = [self.entity] if not recurs: if view is None: if 'vtitle' in self._cw.form: diff -r 83acff1b50cc -r cb14af012a96 web/views/isioc.py --- a/web/views/isioc.py Fri May 21 15:02:56 2010 +0200 +++ b/web/views/isioc.py Fri May 21 15:04:29 2010 +0200 @@ -119,7 +119,7 @@ self.w(u'%s' % entity.modification_date) # XXX format self.w(u'')#entity.isioc_items() - self.w(u'\n' % sioct) + self.w(u'\n' % isioct) class SIOCItemView(EntityView): @@ -156,5 +156,5 @@ self.w(u'\n') self.w(u'')#entity.isioc_topics() self.w(u'')#entity.isioc_replies() - self.w(u' \n' % sioct) + self.w(u' \n' % isioct) diff -r 83acff1b50cc -r cb14af012a96 web/views/timetable.py --- a/web/views/timetable.py Fri May 21 15:02:56 2010 +0200 +++ b/web/views/timetable.py Fri May 21 15:04:29 2010 +0200 @@ -93,7 +93,7 @@ visited_tasks = {} # holds a description of a task for a user task_colors = {} # remember a color assigned to a task - for date in date_range(date_min, date_max): + for date in date_range(date_min, date_max + ONEDAY): columns = [date] d_users = dates.get(date, {}) for user in users: diff -r 83acff1b50cc -r cb14af012a96 web/views/treeview.py --- a/web/views/treeview.py Fri May 21 15:02:56 2010 +0200 +++ b/web/views/treeview.py Fri May 21 15:04:29 2010 +0200 @@ -28,6 +28,7 @@ from cubicweb.utils import make_uid from cubicweb.selectors import implements, adaptable from cubicweb.view import EntityView, EntityAdapter, implements_adapter_compat +from cubicweb.mixins import _done_init from cubicweb.web import json from cubicweb.interfaces import ITree from cubicweb.web.views import baseviews @@ -186,21 +187,6 @@ return path -def _done_init(done, view, row, col): - """handle an infinite recursion safety belt""" - if done is None: - done = set() - entity = view.cw_rset.get_entity(row, col) - if entity.eid in done: - msg = entity._cw._('loop in %(rel)s relation (%(eid)s)') % { - 'rel': entity.tree_attribute, - 'eid': entity.eid - } - return None, msg - done.add(entity.eid) - return done, entity - - class BaseTreeView(baseviews.ListView): """base tree view""" __regid__ = 'tree' diff -r 83acff1b50cc -r cb14af012a96 web/views/xmlrss.py --- a/web/views/xmlrss.py Fri May 21 15:02:56 2010 +0200 +++ b/web/views/xmlrss.py Fri May 21 15:04:29 2010 +0200 @@ -128,7 +128,7 @@ @implements_adapter_compat('IFeed') def rss_feed_url(self): """return an url to the rss feed for this entity""" - return self.absolute_url(vid='rss') + return self.entity.absolute_url(vid='rss') class RSSFeedURL(Component):