move has_format method to the entity schema class tls-sprint
authorsylvain.thenault@logilab.fr
Thu, 12 Mar 2009 16:23:31 +0100
branchtls-sprint
changeset 1090 a99dc223c583
parent 1089 773ec80c8a28
child 1091 b5e253c0dd13
move has_format method to the entity schema class
entity.py
schema.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
--- 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