469 attrs = [] |
469 attrs = [] |
470 for rschema, attrschema in self.e_schema.attribute_definitions(): |
470 for rschema, attrschema in self.e_schema.attribute_definitions(): |
471 if attrschema.type == 'String' and self.has_format(rschema): |
471 if attrschema.type == 'String' and self.has_format(rschema): |
472 attrs.append(rschema.type) |
472 attrs.append(rschema.type) |
473 return attrs |
473 return attrs |
|
474 |
|
475 @classmethod |
|
476 @obsolete('use method of the same name on the schema') |
|
477 def has_format(cls, attr): |
|
478 """return true if this entity's schema has a format field for the given |
|
479 attribute |
|
480 """ |
|
481 return cls.e_schema.has_format(attr) |
474 |
482 |
475 def format(self, attr): |
483 def format(self, attr): |
476 """return the mime type format for an attribute (if specified)""" |
484 """return the mime type format for an attribute (if specified)""" |
477 return getattr(self, '%s_format' % attr, None) |
485 return getattr(self, '%s_format' % attr, None) |
478 |
486 |
479 def text_encoding(self, attr): |
487 def text_encoding(self, attr): |
480 """return the text encoding for an attribute, default to site encoding |
488 """return the text encoding for an attribute, default to site encoding |
481 """ |
489 """ |
482 encoding = getattr(self, '%s_encoding' % attr, None) |
490 encoding = getattr(self, '%s_encoding' % attr, None) |
483 return encoding or self.vreg.property_value('ui.encoding') |
491 return encoding or self.vreg.property_value('ui.encoding') |
484 |
|
485 def has_format(self, attr): |
|
486 """return true if this entity's schema has a format field for the given |
|
487 attribute |
|
488 """ |
|
489 return self.e_schema.has_subject_relation('%s_format' % attr) |
|
490 |
492 |
491 def has_text_encoding(self, attr): |
493 def has_text_encoding(self, attr): |
492 """return true if this entity's schema has ab encoding field for the |
494 """return true if this entity's schema has ab encoding field for the |
493 given attribute |
495 given attribute |
494 """ |
496 """ |