# HG changeset patch # User Sylvain Thénault # Date 1251902527 -7200 # Node ID 8184bec7414d355b6b8906dac33bf13509b49514 # Parent dbbaa628f0f9a3b5d77bc6701b8f94b4987e771c# Parent 72c23fc7fe2065ae30b3994e49bdb95252e1fe64 backport 3.5 diff -r dbbaa628f0f9 -r 8184bec7414d server/hook.py --- a/server/hook.py Wed Sep 02 10:54:04 2009 +0200 +++ b/server/hook.py Wed Sep 02 16:42:07 2009 +0200 @@ -202,10 +202,10 @@ else: assert rtype in self.object_relations meid, seid = toeid, fromeid - rql = 'SET E %s P WHERE X %s P, X eid %%(x)s, E eid %%(e)s, NOT E %s P'\ - % (self.rtype, self.rtype, self.rtype) - rqls = [(rql, {'x': meid, 'e': seid}, ('x', 'e'))] - RQLPrecommitOperation(session, rqls=rqls) + session.unsafe_execute( + 'SET E %s P WHERE X %s P, X eid %%(x)s, E eid %%(e)s, NOT E %s P'\ + % (self.rtype, self.rtype, self.rtype), + {'x': meid, 'e': seid}, ('x', 'e')) class PropagateSubjectRelationAddHook(Hook): @@ -219,19 +219,17 @@ def call(self, session, fromeid, rtype, toeid): eschema = self.schema.eschema(session.describe(fromeid)[0]) - rqls = [] + execute = session.unsafe_execute for rel in self.subject_relations: if eschema.has_subject_relation(rel): - rqls.append(('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' - 'X %s R, NOT R %s P' % (rtype, rel, rtype), - {'x': fromeid, 'p': toeid}, 'x')) + execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' + 'X %s R, NOT R %s P' % (rtype, rel, rtype), + {'x': fromeid, 'p': toeid}, 'x') for rel in self.object_relations: if eschema.has_object_relation(rel): - rqls.append(('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' - 'R %s X, NOT R %s P' % (rtype, rel, rtype), - {'x': fromeid, 'p': toeid}, 'x')) - if rqls: - RQLPrecommitOperation(session, rqls=rqls) + execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' + 'R %s X, NOT R %s P' % (rtype, rel, rtype), + {'x': fromeid, 'p': toeid}, 'x') class PropagateSubjectRelationDelHook(Hook): @@ -245,19 +243,17 @@ def call(self, session, fromeid, rtype, toeid): eschema = self.schema.eschema(session.describe(fromeid)[0]) - rqls = [] + execute = session.unsafe_execute for rel in self.subject_relations: if eschema.has_subject_relation(rel): - rqls.append(('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' - 'X %s R' % (rtype, rel), - {'x': fromeid, 'p': toeid}, 'x')) + execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' + 'X %s R' % (rtype, rel), + {'x': fromeid, 'p': toeid}, 'x') for rel in self.object_relations: if eschema.has_object_relation(rel): - rqls.append(('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' - 'R %s X' % (rtype, rel), - {'x': fromeid, 'p': toeid}, 'x')) - if rqls: - RQLPrecommitOperation(session, rqls=rqls) + execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, ' + 'R %s X' % (rtype, rel), + {'x': fromeid, 'p': toeid}, 'x') # abstract classes for operation ############################################### diff -r dbbaa628f0f9 -r 8184bec7414d server/hooksmanager.py --- a/server/hooksmanager.py Wed Sep 02 10:54:04 2009 +0200 +++ b/server/hooksmanager.py Wed Sep 02 16:42:07 2009 +0200 @@ -5,3 +5,4 @@ PropagateSubjectRelationAddHook = class_renamed('PropagateSubjectRelationAddHook', Hook) PropagateSubjectRelationDelHook = class_renamed('PropagateSubjectRelationDelHook', Hook) Hook = class_moved(Hook) + diff -r dbbaa628f0f9 -r 8184bec7414d web/views/ibreadcrumbs.py --- a/web/views/ibreadcrumbs.py Wed Sep 02 10:54:04 2009 +0200 +++ b/web/views/ibreadcrumbs.py Wed Sep 02 16:42:07 2009 +0200 @@ -16,14 +16,8 @@ from cubicweb.view import EntityView, Component # don't use AnyEntity since this may cause bug with isinstance() due to reloading from cubicweb.entity import Entity -from cubicweb.common.uilib import cut - +from cubicweb.common import tags, uilib -def bc_title(entity): - textsize = entity.req.property_value('navigation.short-line-size') - return xml_escape(cut(entity.dc_title(), textsize)) - -# XXX only provides the component version class BreadCrumbEntityVComponent(Component): id = 'breadcrumbs' @@ -38,7 +32,7 @@ separator = u' > ' def call(self, view=None, first_separator=True): - entity = self.rset.get_entity(0,0) + entity = self.rset.get_entity(0, 0) path = entity.breadcrumbs(view) if path: self.w(u'') @@ -62,17 +56,17 @@ def wpath_part(self, part, contextentity, last=False): if isinstance(part, Entity): if last and part.eid == contextentity.eid: - self.w(bc_title(part)) + part.view('breadcrumbtext', w=self.w) else: part.view('breadcrumbs', w=self.w) elif isinstance(part, tuple): url, title = part textsize = self.req.property_value('navigation.short-line-size') self.w(u'%s' % ( - xml_escape(url), xml_escape(cut(title, textsize)))) + xml_escape(url), xml_escape(uilib.cut(title, textsize)))) else: textsize = self.req.property_value('navigation.short-line-size') - self.w(cut(unicode(part), textsize)) + self.w(uilib.cut(unicode(part), textsize)) class BreadCrumbETypeVComponent(BreadCrumbEntityVComponent): @@ -104,6 +98,15 @@ def cell_call(self, row, col): entity = self.rset.get_entity(row, col) - desc = xml_escape(cut(entity.dc_description(), 50)) - self.w(u'%s' % ( - xml_escape(entity.absolute_url()), desc, bc_title(entity))) + desc = xml_escape(uilib.cut(entity.dc_description(), 50)) + self.w(tags.a(entity.view('breadcrumbtext'), href=entity.absolute_url(), + title=desc)) + + +class BreadCrumbTextView(EntityView): + id = 'breadcrumbtext' + + def cell_call(self, row, col): + entity = self.rset.get_entity(row, col) + textsize = self.req.property_value('navigation.short-line-size') + self.w(uilib.cut(entity.dc_title(), textsize))