other fixlets tls-sprint
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 28 Apr 2009 20:08:16 +0200
branchtls-sprint
changeset 1528 864ae7c15ef5
parent 1527 c8ca1782e252
child 1529 7d1794175e40
other fixlets
rtags.py
web/form.py
web/views/autoform.py
web/views/editforms.py
--- a/rtags.py	Tue Apr 28 20:05:59 2009 +0200
+++ b/rtags.py	Tue Apr 28 20:08:16 2009 +0200
@@ -22,6 +22,9 @@
         self.use_set = use_set
         self._tagdefs = {}
 
+    def __repr__(self):
+        return repr(self._tagdefs)
+
     def set_rtag(self, tag, rtype, role, stype='*', otype='*'):
         assert not self.use_set
         assert role in ('subject', 'object'), role
--- a/web/form.py	Tue Apr 28 20:05:59 2009 +0200
+++ b/web/form.py	Tue Apr 28 20:08:16 2009 +0200
@@ -489,7 +489,7 @@
         """overriden to add edit[s|o] hidden fields and to ensure schema fields
         have eidparam set to True
 
-        edit[s|o] hidden fields are used t o indicate the value for the
+        edit[s|o] hidden fields are used to indicate the value for the
         associated field before the (potential) modification made when
         submitting the form.
         """
@@ -608,7 +608,7 @@
         """
         entity = self.edited_entity
         if isinstance(rtype, basestring):
-            rtype = self.schema.rschema(rtype)
+            rtype = entity.schema.rschema(rtype)
         done = None
         assert not rtype.is_final(), rtype
         if entity.has_eid():
@@ -630,7 +630,7 @@
         """
         entity = self.edited_entity
         if isinstance(rtype, basestring):
-            rtype = self.schema.rschema(rtype)
+            rtype = entity.schema.rschema(rtype)
         done = None
         if entity.has_eid():
             done = set(e.eid for e in getattr(entity, 'reverse_%s' % rtype))
--- a/web/views/autoform.py	Tue Apr 28 20:05:59 2009 +0200
+++ b/web/views/autoform.py	Tue Apr 28 20:08:16 2009 +0200
@@ -13,6 +13,8 @@
 from cubicweb.web.form import FieldNotFound, EntityFieldsForm
 from cubicweb.web.formfields import guess_field
 from cubicweb.web.formwidgets import Button, SubmitButton
+from cubicweb.web.views.editforms import toggleable_relation_link, relation_id
+
 _ = unicode
 
 class AutomaticEntityForm(EntityFieldsForm):
@@ -241,7 +243,7 @@
     def editable_attributes(self):
         """return a list of (relation schema, role) to edit for the entity"""
         return [(rschema, x) for rschema, _, x in self.relations_by_category(
-            self.attrcategories, 'add') if rschema != 'eid']
+                self.attrcategories, 'add') if rschema != 'eid']
 
     def relations_table(self):
         """yiels 3-tuples (rtype, target, related_list)
@@ -256,9 +258,9 @@
         for label, rschema, role in self.srelations_by_category('generic', 'add'):
             relatedrset = entity.related(rschema, role, limit=self.related_limit)
             if rschema.has_perm(self.req, 'delete'):
-                toggable_rel_link_func = toggable_relation_link
+                toggleable_rel_link_func = toggleable_relation_link
             else:
-                toggable_rel_link_func = lambda x, y, z: u''
+                toggleable_rel_link_func = lambda x, y, z: u''
             related = []
             for row in xrange(relatedrset.rowcount):
                 nodeid = relation_id(entity.eid, rschema, role,
@@ -269,7 +271,7 @@
                 else:
                     status = u''
                     label = 'x'
-                dellink = toggable_rel_link_func(entity.eid, nodeid, label)
+                dellink = toggleable_rel_link_func(entity.eid, nodeid, label)
                 eview = self.view('oneline', relatedrset, row=row)
                 related.append((nodeid, dellink, status, eview))
             yield (rschema, role, related)
--- a/web/views/editforms.py	Tue Apr 28 20:05:59 2009 +0200
+++ b/web/views/editforms.py	Tue Apr 28 20:08:16 2009 +0200
@@ -33,7 +33,7 @@
         return u'%s:%s:%s' % (eid, rtype, reid)
     return u'%s:%s:%s' % (reid, rtype, eid)
 
-def toggable_relation_link(eid, nodeid, label='x'):
+def toggleable_relation_link(eid, nodeid, label='x'):
     """return javascript snippet to delete/undelete a relation between two
     entities
     """