merge changes from oldstable stable
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Fri, 29 Apr 2011 19:31:25 +0200
branchstable
changeset 7288 b156200ebc9d
parent 7280 571b29842ef1 (current diff)
parent 7287 601ad29268ab (diff)
child 7289 f91e8e25510c
merge changes from oldstable
entity.py
server/hook.py
--- a/doc/book/en/tutorials/advanced/part02_security.rst	Fri Apr 29 10:29:25 2011 +0200
+++ b/doc/book/en/tutorials/advanced/part02_security.rst	Fri Apr 29 19:31:25 2011 +0200
@@ -190,9 +190,10 @@
     from cubicweb.selectors import is_instance
     from cubicweb.server import hook
 
-    class SetVisibilityOp(hook.Operation):
+    class SetVisibilityOp(hook.DataOperationMixIn, hook.Operation):
+
 	def precommit_event(self):
-	    for eid in self.session.transaction_data.pop('pending_visibility'):
+	    for eid in self.get_data():
 		entity = self.session.entity_from_eid(eid)
 		if entity.visibility == 'parent':
 		    entity.set_attributes(visibility=u'authenticated')
@@ -201,9 +202,9 @@
 	__regid__ = 'sytweb.setvisibility'
 	__select__ = hook.Hook.__select__ & is_instance('Folder', 'File', 'Comment')
 	events = ('after_add_entity',)
+
 	def __call__(self):
-	    hook.set_operation(self._cw, 'pending_visibility', self.entity.eid,
-			       SetVisibilityOp)
+	    SetVisibilityOp.get_instance(self._cw).add_data(self.entity.eid)
 
     class SetParentVisibilityHook(hook.Hook):
 	__regid__ = 'sytweb.setparentvisibility'
@@ -240,7 +241,7 @@
   - `self.entity` is the newly added entity on 'after_add_entity' events
 
   - `self.eidfrom` / `self.eidto` are the eid of the subject / object entity on
-    'after_add_relatiohn' events (you may also get the relation type using
+    'after_add_relation' events (you may also get the relation type using
     `self.rtype`)
 
 The `parent` visibility value is used to tell "propagate using parent security"
@@ -381,7 +382,7 @@
 test instance. The second one will be much quicker:
 
 .. sourcecode:: bash
-    
+
     $ pytest unittest_sytweb.py
     ========================  unittest_sytweb.py  ========================
     .
--- a/entity.py	Fri Apr 29 10:29:25 2011 +0200
+++ b/entity.py	Fri Apr 29 19:31:25 2011 +0200
@@ -272,7 +272,7 @@
                 role = 'object'
             else:
                 role = 'subject'
-            assert eschema.has_relation(attr, role)
+            assert eschema.has_relation(attr, role), '%s %s not found on %s' % (attr, role, eschema)
             rschema = eschema.subjrels[attr] if role == 'subject' else eschema.objrels[attr]
             if not rschema.final and isinstance(value, (tuple, list, set, frozenset)):
                 if len(value) == 1:
--- a/server/hook.py	Fri Apr 29 10:29:25 2011 +0200
+++ b/server/hook.py	Fri Apr 29 19:31:25 2011 +0200
@@ -812,9 +812,9 @@
     by redefining :meth:`_build_container` and :meth:`add_data`
 
     More optional parameters can be given to the `get_instance` operation, that
-    will be given to the operation constructer (though those parameters should
-    not vary accross different calls to this method for a same operation for
-    obvious reason).
+    will be given to the operation constructor (for obvious reasons those
+    parameters should not vary accross different calls to this method for a
+    given operation).
 
     .. Note::
         For sanity reason `get_data` will reset the operation, so that once