# HG changeset patch # User Sylvain Thénault # Date 1260259816 -3600 # Node ID 24f7d7eb4c23917226c462d660c2ca84c2a2a68f # Parent f0d1038e5059daf2e3574d50cb12d102576796f3 yams api update diff -r f0d1038e5059 -r 24f7d7eb4c23 server/schemaserial.py --- a/server/schemaserial.py Tue Dec 08 09:09:07 2009 +0100 +++ b/server/schemaserial.py Tue Dec 08 09:10:16 2009 +0100 @@ -399,7 +399,7 @@ if subjtype is None: assert objtype is None assert props is None - targets = rschema.iter_rdefs() + targets = rschema.rdefs else: assert not objtype is None targets = [(subjtype, objtype)] diff -r f0d1038e5059 -r 24f7d7eb4c23 web/formfields.py --- a/web/formfields.py Tue Dec 08 09:09:07 2009 +0100 +++ b/web/formfields.py Tue Dec 08 09:10:16 2009 +0100 @@ -583,27 +583,25 @@ 'subjschema rschema objschema' according to information found in the schema """ fieldclass = None - card = eschema.cardinality(rschema, role) + rdef = eschema.rdef(rschema, role) if role == 'subject': - targetschema = rschema.objects(eschema)[0] - help = rschema.rproperty(eschema, targetschema, 'description') + targetschema = rdef.object if rschema.final: - if rschema.rproperty(eschema, targetschema, 'internationalizable'): + if rdef.internationalizable: kwargs.setdefault('internationalizable', True) def get_default(form, es=eschema, rs=rschema): return es.default(rs) kwargs.setdefault('initial', get_default) else: - targetschema = rschema.subjects(eschema)[0] - help = rschema.rproperty(targetschema, eschema, 'description') - kwargs['required'] = card in '1+' + targetschema = rdef.subject + kwargs['required'] = rdef.role_cardinality(role) in '1+' kwargs['name'] = rschema.type if role == 'object': kwargs.setdefault('label', (eschema.type, rschema.type + '_object')) else: kwargs.setdefault('label', (eschema.type, rschema.type)) kwargs['eidparam'] = True - kwargs.setdefault('help', help) + kwargs.setdefault('help', rdef.description) if rschema.final: if skip_meta_attr and rschema in eschema.meta_attributes(): return None @@ -617,18 +615,16 @@ # use RichTextField instead of StringField if the attribute has # a "format" metadata. But getting information from constraints # may be useful anyway... - constraints = rschema.rproperty(eschema, targetschema, 'constraints') - for cstr in constraints: + for cstr in rdef.constraints: if isinstance(cstr, StaticVocabularyConstraint): raise Exception('rich text field with static vocabulary') return RichTextField(**kwargs) - constraints = rschema.rproperty(eschema, targetschema, 'constraints') # init StringField parameters according to constraints - for cstr in constraints: + for cstr in rdef.constraints: if isinstance(cstr, StaticVocabularyConstraint): kwargs.setdefault('choices', cstr.vocabulary) break - for cstr in constraints: + for cstr in rdef.constraints: if isinstance(cstr, SizeConstraint) and cstr.max is not None: kwargs['max_length'] = cstr.max return StringField(**kwargs)