# HG changeset patch # User Sandrine Ribeau # Date 1260287691 28800 # Node ID 7cc66b1d9183031a677f4cc418216447ec6a4907 # Parent 0c39ffd789edb4d280a09b40a1c05d16aa73b559 more api update diff -r 0c39ffd789ed -r 7cc66b1d9183 devtools/fill.py --- a/devtools/fill.py Tue Dec 08 18:05:10 2009 +0100 +++ b/devtools/fill.py Tue Dec 08 07:54:51 2009 -0800 @@ -30,7 +30,7 @@ """returns possible choices for 'attrname' if attrname doesn't have ChoiceConstraint, return None """ - for cst in eschema.constraints(attrname): + for cst in eschema.rdef(attrname).constraints: if isinstance(cst, StaticVocabularyConstraint): return cst.vocabulary() return None @@ -38,14 +38,14 @@ def get_max_length(eschema, attrname): """returns the maximum length allowed for 'attrname'""" - for cst in eschema.constraints(attrname): + for cst in eschema.rdef(attrname).constraints: if isinstance(cst, SizeConstraint) and cst.max: return cst.max return 300 #raise AttributeError('No Size constraint on attribute "%s"' % attrname) def get_bounds(eschema, attrname): - for cst in eschema.constraints(attrname): + for cst in eschema.rdef(attrname).constraints: if isinstance(cst, IntervalBoundConstraint): return cst.minvalue, cst.maxvalue return None, None @@ -340,10 +340,10 @@ def composite_relation(rschema): for obj in rschema.objects(): - if obj.objrproperty(rschema, 'composite') == 'subject': + if obj.rdef(rschema, 'object').composite == 'subject': return True for obj in rschema.subjects(): - if obj.subjrproperty(rschema, 'composite') == 'object': + if obj.rdef(rschema, 'subject').composite == 'object': return True return False @@ -372,11 +372,11 @@ oedict = deepcopy(edict) delayed = [] # for each couple (subjschema, objschema), insert relations - for subj, obj in rschema.iter_rdefs(): + for subj, obj in rschema.rdefs: sym.add( (subj, obj) ) if rschema.symetric and (obj, subj) in sym: continue - subjcard, objcard = rschema.rproperty(subj, obj, 'cardinality') + subjcard, objcard = rschema.rdef(subj, obj).cardinality # process mandatory relations first if subjcard in '1+' or objcard in '1+' or composite_relation(rschema): for query, args in self.make_relation_queries(sedict, oedict, @@ -397,14 +397,15 @@ return {'subjeid' : subjeid, 'objeid' : objeid} def make_relation_queries(self, sedict, oedict, rschema, subj, obj): - subjcard, objcard = rschema.rproperty(subj, obj, 'cardinality') + rdef = rschema.rdef(subj, obj) + subjcard, objcard = rdef.cardinality subjeids = sedict.get(subj, frozenset()) used = self.existingrels[rschema.type] preexisting_subjrels = set(subj for subj, obj in used) preexisting_objrels = set(obj for subj, obj in used) # if there are constraints, only select appropriate objeids q = self.rql_tmpl % rschema.type - constraints = [c for c in rschema.rproperty(subj, obj, 'constraints') + constraints = [c for c in rdef.constraints if isinstance(c, RQLConstraint)] if constraints: restrictions = ', '.join(c.restriction for c in constraints) diff -r 0c39ffd789ed -r 7cc66b1d9183 devtools/testlib.py --- a/devtools/testlib.py Tue Dec 08 18:05:10 2009 +0100 +++ b/devtools/testlib.py Tue Dec 08 07:54:51 2009 -0800 @@ -693,8 +693,8 @@ for rschema in schema.relations(): if rschema.final: continue - for subj, obj in rschema.iter_rdefs(): - card = rschema.rproperty(subj, obj, 'cardinality') + for subj, obj in rschema.rdefs: + card = rschema.rdef(subj, obj).cardinality if card[0] in '1?' and len(rschema.subjects(obj)) == 1: relmap.setdefault((rschema, subj), []).append(str(obj)) if card[1] in '1?' and len(rschema.objects(subj)) == 1: diff -r 0c39ffd789ed -r 7cc66b1d9183 web/views/editcontroller.py --- a/web/views/editcontroller.py Tue Dec 08 18:05:10 2009 +0100 +++ b/web/views/editcontroller.py Tue Dec 08 07:54:51 2009 -0800 @@ -174,12 +174,12 @@ try: for attr, value in field.process_posted(form): if not ( - (field.role == 'subject' and eschema.has_subject_relation(field.name)) + (field.role == 'subject' and field.name in eschema.subjrels) or - (field.role == 'object' and eschema.has_object_relation(field.name))): + (field.role == 'object' and field.name in eschema.objrels)): continue rschema = self._cw.vreg.schema.rschema(field.name) - if rschema.is_final(): + if rschema.final: rqlquery.kwargs[attr] = value rqlquery.edited.append('X %s %%(%s)s' % (attr, attr)) elif rschema.inlined: diff -r 0c39ffd789ed -r 7cc66b1d9183 web/views/editforms.py --- a/web/views/editforms.py Tue Dec 08 18:05:10 2009 +0100 +++ b/web/views/editforms.py Tue Dec 08 07:54:51 2009 -0800 @@ -205,7 +205,7 @@ w(form.render(renderer=renderer)) w(u'') w(u'')