[hook] remove assumption about entity cache vs cw_edited
We were assuming that if an entity is in the connection's cache, it has
a cw_edited attribute. This doesn't seem to always be the case. At
least in cubicweb 3.21, merging the web and repo-side caches makes this
more likely, but Denis says he's also seen this on 3.20.
--- a/hooks/security.py Tue Jul 21 18:09:12 2015 +0200
+++ b/hooks/security.py Tue Jul 21 18:17:31 2015 +0200
@@ -146,7 +146,10 @@
entity = cnx.entity_cache(eid)
except KeyError:
return False
- return rschema.type in entity.cw_edited.skip_security
+ edited = getattr(entity, 'cw_edited', None)
+ if edited is None:
+ return False
+ return rschema.type in edited.skip_security
class BeforeAddRelationSecurityHook(SecurityHook):