# HG changeset patch # User Sandrine Ribeau # Date 1260191349 28800 # Node ID b9436fe77c9e8ab359e631acf0917867dbee73ec # Parent 94cc7cad3d2d0d8d85a20ccbdf0bcb809c410084 fix bad merge diff -r 94cc7cad3d2d -r b9436fe77c9e hooks/integrity.py --- a/hooks/integrity.py Thu Dec 03 17:17:43 2009 +0100 +++ b/hooks/integrity.py Mon Dec 07 05:09:09 2009 -0800 @@ -167,7 +167,7 @@ entity = self.entity for attr in entity.edited_attributes: if schema.rschema(attr).final: - constraints = [c for c in entity.rdef(attr).constraints + constraints = [c for c in entity.e_schema.rdef(attr).constraints if isinstance(c, (RQLUniqueConstraint, RQLConstraint))] if constraints: _CheckConstraintsOp(self._cw, constraints=constraints, diff -r 94cc7cad3d2d -r b9436fe77c9e hooks/security.py --- a/hooks/security.py Thu Dec 03 17:17:43 2009 +0100 +++ b/hooks/security.py Mon Dec 07 05:09:09 2009 -0800 @@ -119,7 +119,7 @@ eidfrom=self.eidfrom, eidto=self.eidto) else: - rdef = rschema.rdef(session.describe(self.eidfrom)[0], - session.describe(self.eidto)[0]) - rdef.check_perm(session, 'add', fromeid=self.eidfrom, toeid=self.eidto) + rdef = rschema.rdef(self._cw.describe(self.eidfrom)[0], + self._cw.describe(self.eidto)[0]) + rdef.check_perm(self._cw, 'add', fromeid=self.eidfrom, toeid=self.eidto) diff -r 94cc7cad3d2d -r b9436fe77c9e hooks/syncschema.py --- a/hooks/syncschema.py Thu Dec 03 17:17:43 2009 +0100 +++ b/hooks/syncschema.py Mon Dec 07 05:09:09 2009 -0800 @@ -781,7 +781,6 @@ * register an operation to add the entity type to the instance's schema on commit """ -<<<<<<< /home/syt/src/fcubicweb/cubicweb/hooks/syncschema.py __regid__ = 'syncaddcwetype' events = ('after_add_entity',) diff -r 94cc7cad3d2d -r b9436fe77c9e hooks/workflow.py --- a/hooks/workflow.py Thu Dec 03 17:17:43 2009 +0100 +++ b/hooks/workflow.py Mon Dec 07 05:09:09 2009 -0800 @@ -227,7 +227,7 @@ msg = session._("transition %s isn't allowed from %s") % ( _(tr.name), _(fromstate.name)) raise ValidationError(entity.eid, {'by_transition': msg}) - if not tr.may_be_fired(foreid): + if not tr.may_be_fired(foreid): msg = session._("transition may not be fired") raise ValidationError(entity.eid, {'by_transition': msg}) if entity.get('to_state'): diff -r 94cc7cad3d2d -r b9436fe77c9e schema.py --- a/schema.py Thu Dec 03 17:17:43 2009 +0100 +++ b/schema.py Mon Dec 07 05:09:09 2009 -0800 @@ -527,6 +527,7 @@ self._eid_index[rdef.eid] = rdefs except AttributeError: pass # not a serialized schema + return rdefs def del_relation_type(self, rtype): rschema = self.rschema(rtype) diff -r 94cc7cad3d2d -r b9436fe77c9e schemas/base.py --- a/schemas/base.py Thu Dec 03 17:17:43 2009 +0100 +++ b/schemas/base.py Mon Dec 07 05:09:09 2009 -0800 @@ -135,30 +135,6 @@ object = 'String' -class CWProperty(EntityType): - """used for cubicweb configuration. Once a property has been created you - can't change the key. - """ - __permissions__ = { - 'read': ('managers', 'users', 'guests'), - 'add': ('managers', 'users',), - 'update': ('managers', 'owners',), - 'delete': ('managers', 'owners',), - } - # key is a reserved word for mysql - pkey = String(required=True, internationalizable=True, maxsize=256, - description=_('defines what\'s the property is applied for. ' - 'You must select this first to be able to set ' - 'value')) - value = String(internationalizable=True, maxsize=256) - - for_user = SubjectRelation('CWUser', cardinality='?*', composite='object', - description=_('user for which this property is ' - 'applying. If this relation is not ' - 'set, the property is considered as' - ' a global property')) - - # XXX find a better relation name class for_user(RelationType): """link a property to the user which want this property customization. Unless diff -r 94cc7cad3d2d -r b9436fe77c9e schemas/bootstrap.py --- a/schemas/bootstrap.py Thu Dec 03 17:17:43 2009 +0100 +++ b/schemas/bootstrap.py Mon Dec 07 05:09:09 2009 -0800 @@ -177,7 +177,7 @@ """used for cubicweb configuration. Once a property has been created you can't change the key. """ - permissions = { + __permissions__ = { 'read': ('managers', 'users', 'guests'), 'add': ('managers', 'users',), 'update': ('managers', 'owners',), diff -r 94cc7cad3d2d -r b9436fe77c9e server/schemaserial.py --- a/server/schemaserial.py Thu Dec 03 17:17:43 2009 +0100 +++ b/server/schemaserial.py Mon Dec 07 05:09:09 2009 -0800 @@ -183,7 +183,6 @@ fulltext_container=ft_container, eid=eid) rschema = schema.add_relation_type(rtype) index[eid] = rschema - set_perms(rschema, permsdict.get(eid, {})) cstrsdict = deserialize_rdef_constraints(session) for values in session.execute( 'Any X,SE,RT,OE,CARD,ORD,DESC,IDX,FTIDX,I18N,DFLT WHERE X is CWAttribute,' @@ -202,7 +201,8 @@ indexed=idx, fulltextindexed=ftidx, internationalizable=i18n, default=default, eid=rdefeid) - schema.add_relation_def(rdef) + rdefs = schema.add_relation_def(rdef) + set_perms(rdefs, permsdict.get(rdefeid, {})) for values in session.execute( 'Any X,SE,RT,OE,CARD,ORD,DESC,C WHERE X is CWRelation, X relation_type RT,' 'X cardinality CARD, X ordernum ORD, X description DESC, ' @@ -216,7 +216,8 @@ order=ord, description=desc, composite=c, constraints=constraints, eid=rdefeid) - schema.add_relation_def(rdef) + rdefs = schema.add_relation_def(rdef) + set_perms(rdefs, permsdict.get(rdefeid, {})) schema.infer_specialization_rules() if _3_2_migration: _update_database(schema, sqlcu) @@ -363,7 +364,7 @@ amap = {'order': 'ordernum'} values = {} for prop, default in rschema.rproperty_defs(objtype).iteritems(): - if prop in ('eid', 'constraints', 'uid', 'infered'): + if prop in ('eid', 'constraints', 'uid', 'infered', 'permissions'): continue value = props.get(prop, default) if prop in ('indexed', 'fulltextindexed', 'internationalizable'): @@ -536,7 +537,7 @@ else: # entity schema for rql, args in _erperms2rql(erschema, groupmapping): - args['name'] = str(eschema) + args['name'] = str(erschema) yield rql + 'X is CWEType, X name %(name)s', args def _erperms2rql(erschema, groupmapping): @@ -550,7 +551,7 @@ if isinstance(group_or_rqlexpr, basestring): # group try: - yield ('SET X %s_permission Y WHERE Y eid %%(g)s' % action, + yield ('SET X %s_permission Y WHERE Y eid %%(g)s, ' % action, {'g': groupmapping[group_or_rqlexpr]}) except KeyError: continue diff -r 94cc7cad3d2d -r b9436fe77c9e web/form.py --- a/web/form.py Thu Dec 03 17:17:43 2009 +0100 +++ b/web/form.py Mon Dec 07 05:09:09 2009 -0800 @@ -36,8 +36,6 @@ return False -<<<<<<< /home/syt/src/fcubicweb/cubicweb/web/form.py -======= # XXX should disappear class FormMixIn(object): """abstract form mix-in @@ -192,7 +190,6 @@ ############################################################################### ->>>>>>> /tmp/form.py~other.xdns1y class metafieldsform(type): """metaclass for FieldsForm to retrieve fields defined as class attributes and put them into a single ordered list: '_fields_'. diff -r 94cc7cad3d2d -r b9436fe77c9e web/uicfg.py --- a/web/uicfg.py Thu Dec 03 17:17:43 2009 +0100 +++ b/web/uicfg.py Mon Dec 07 05:09:09 2009 -0800 @@ -233,12 +233,13 @@ return result def _card_and_comp(sschema, rschema, oschema, role): + rdef = rschema.rdef(sschema, oschema) if role == 'subject': - card = rschema.rproperty(sschema, oschema, 'cardinality')[0] - composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' + card = rdef.cardinality[0] + composed = not rschema.final and rdef.composite == 'object' else: - card = rschema.rproperty(sschema, oschema, 'cardinality')[1] - composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' + card = rdef.cardinality[1] + composed = not rschema.final and rdef.composite == 'subject' return card, composed class AutoformSectionRelationTags(RelationTagsSet): @@ -356,12 +357,12 @@ _targetschemas = [] for tschema in targetschemas: if not rtags.etype_get(eschema, rschema, role, tschema) in categories: - continue - rdef = rschema.role_rdef(eschema, tschema, role) - if not ((not strict and rdef.has_local_role(permission)) or - rdef.has_perm(entity.req, permission, fromeid=eid)): - continue - _targetschemas.append(tschema) + continue + rdef = rschema.role_rdef(eschema, tschema, role) + if not ((not strict and rdef.has_local_role(permission)) or + rdef.has_perm(entity.req, permission, fromeid=eid)): + continue + _targetschemas.append(tschema) if not _targetschemas: continue targetschemas = _targetschemas diff -r 94cc7cad3d2d -r b9436fe77c9e web/views/autoform.py --- a/web/views/autoform.py Thu Dec 03 17:17:43 2009 +0100 +++ b/web/views/autoform.py Mon Dec 07 05:09:09 2009 -0800 @@ -50,94 +50,6 @@ # class methods mapping schema relations to fields in the form ############ -<<<<<<< /home/syt/src/fcubicweb/cubicweb/web/views/autoform.py -======= - @classmethod - def erelations_by_category(cls, entity, categories=None, permission=None, - rtags=None, strict=False): - """return a list of (relation schema, target schemas, role) matching - categories and permission - - `strict`: - bool telling if having local role is enough (strict = False) or not - """ - if categories is not None: - if not isinstance(categories, (list, tuple, set, frozenset)): - categories = (categories,) - if not isinstance(categories, (set, frozenset)): - categories = frozenset(categories) - eschema = entity.e_schema - if rtags is None: - rtags = cls.rcategories - permsoverrides = cls.rpermissions_overrides - if entity.has_eid(): - eid = entity.eid - else: - eid = None - strict = False - for rschema, targetschemas, role in eschema.relation_definitions(True): - # check category first, potentially lower cost than checking - # permission which may imply rql queries - if categories is not None: - _targetschemas = [] - for tschema in targetschemas: - if not rtags.etype_get(eschema, rschema, role, tschema) in categories: - continue - rdef = rschema.role_rdef(eschema, tschema, role) - if not ((not strict and rdef.has_local_role(permission)) or - rdef.has_perm(entity.req, permission, fromeid=eid)): - continue - _targetschemas.append(tschema) - if not _targetschemas: - continue - targetschemas = _targetschemas - if permission is not None: - # tag allowing to hijack the permission machinery when - # permission is not verifiable until the entity is actually - # created... - if eid is None and '%s_on_new' % permission in permsoverrides.etype_get(eschema, rschema, role): - yield (rschema, targetschemas, role) - continue - if rschema.final: - if not eschema.rdef(rschema).has_perm(entity.req, permission, eid=eid): - continue - elif role == 'subject': - # on relation with cardinality 1 or ?, we need delete perm as well - # if the relation is already set - if (permission == 'add' - and rschema.rdef(eschema, targetschemas[0]).role_cardinality(role) in '1?' - and eid and entity.related(rschema.type, role) - and not rschema.has_perm(entity.req, 'delete', fromeid=eid, - toeid=entity.related(rschema.type, role)[0][0])): - continue - elif role == 'object': - # on relation with cardinality 1 or ?, we need delete perm as well - # if the relation is already set - if (permission == 'add' - and rschema.rdef(targetschemas[0], eschema).role_cardinality(role) in '1?' - and eid and entity.related(rschema.type, role) - and not rschema.has_perm(entity.req, 'delete', toeid=eid, - fromeid=entity.related(rschema.type, role)[0][0])): - continue - yield (rschema, targetschemas, role) - - @classmethod - def esrelations_by_category(cls, entity, categories=None, permission=None, - strict=False): - """filter out result of relations_by_category(categories, permission) by - removing final relations - - return a sorted list of (relation's label, relation'schema, role) - """ - result = [] - for rschema, ttypes, role in cls.erelations_by_category( - entity, categories, permission, strict=strict): - if rschema.final: - continue - result.append((rschema.display_name(entity.req, role), rschema, role)) - return sorted(result) - ->>>>>>> /tmp/autoform.py~other.rHDQ-C @iclassmethod def field_by_name(cls_or_self, name, role='subject', eschema=None): """return field with the given name and role. If field is not explicitly diff -r 94cc7cad3d2d -r b9436fe77c9e web/views/basecontrollers.py --- a/web/views/basecontrollers.py Thu Dec 03 17:17:43 2009 +0100 +++ b/web/views/basecontrollers.py Mon Dec 07 05:09:09 2009 -0800 @@ -249,12 +249,7 @@ note: it's the responsability of js_* methods to set the correct response content type """ -<<<<<<< /home/syt/src/fcubicweb/cubicweb/web/views/basecontrollers.py self._cw.json_request = True - self._cw.pageid = self._cw.form.get('pageid') -======= - self.req.json_request = True ->>>>>>> /tmp/basecontrollers.py~other.K2YVFx try: fname = self._cw.form['fname'] func = getattr(self, 'js_%s' % fname) diff -r 94cc7cad3d2d -r b9436fe77c9e web/views/owl.py --- a/web/views/owl.py Thu Dec 03 17:17:43 2009 +0100 +++ b/web/views/owl.py Mon Dec 07 05:09:09 2009 -0800 @@ -71,15 +71,9 @@ if writeprefix: self.w(OWL_CLOSING_ROOT) -<<<<<<< /home/syt/src/fcubicweb/cubicweb/web/views/owl.py - def should_display_rschema(self, rschema): - return not rschema in self.skiptypes and ( - rschema.has_local_role('read') or - rschema.has_perm(self._cw, 'read')) -======= def should_display_rschema(self, eschema, rschema, tschemas, role): - return rschema.may_have_permissions('read', self.req, eschema, role) ->>>>>>> /tmp/owl.py~other.-maWGS + return not rschema in self.skiptypes and ( + rschema.may_have_permissions('read', self._cw, eschema, role)) def visit_schema(self, skiptypes): """get a layout for a whole schema"""