# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1236871411 -3600 # Node ID a99dc223c583a1ae48132a212806fc9e7d5c58ea # Parent 773ec80c8a2868f4a102ea19ff12467d7d495343 move has_format method to the entity schema class diff -r 773ec80c8a28 -r a99dc223c583 entity.py --- a/entity.py Thu Mar 12 16:23:00 2009 +0100 +++ b/entity.py Thu Mar 12 16:23:31 2009 +0100 @@ -471,6 +471,14 @@ if attrschema.type == 'String' and self.has_format(rschema): attrs.append(rschema.type) return attrs + + @classmethod + @obsolete('use method of the same name on the schema') + def has_format(cls, attr): + """return true if this entity's schema has a format field for the given + attribute + """ + return cls.e_schema.has_format(attr) def format(self, attr): """return the mime type format for an attribute (if specified)""" @@ -481,12 +489,6 @@ """ encoding = getattr(self, '%s_encoding' % attr, None) return encoding or self.vreg.property_value('ui.encoding') - - def has_format(self, attr): - """return true if this entity's schema has a format field for the given - attribute - """ - return self.e_schema.has_subject_relation('%s_format' % attr) def has_text_encoding(self, attr): """return true if this entity's schema has ab encoding field for the diff -r 773ec80c8a28 -r a99dc223c583 schema.py --- a/schema.py Thu Mar 12 16:23:00 2009 +0100 +++ b/schema.py Thu Mar 12 16:23:31 2009 +0100 @@ -323,6 +323,12 @@ """return True if this entity type is used to build the schema""" return self.type in self.schema.schema_entity_types() + def has_format(self, attr): + """return true if this entity's schema has a format field for the given + attribute + """ + return self.has_subject_relation('%s_format' % attr) + def rich_text_fields(self): """return an iterator on (attribute, format attribute) of rich text field