--- a/entities/__init__.py Wed Apr 15 14:07:30 2009 +0200
+++ b/entities/__init__.py Wed Apr 15 14:41:06 2009 +0200
@@ -306,7 +306,7 @@
"""
if self.req.use_fckeditor() and self.e_schema.has_metadata(attr, 'format'):
if self.has_eid() or '%s_format' % attr in self:
- return self.attribute_metadata(attr, 'format') == 'text/html'
+ return self.attr_metadata(attr, 'format') == 'text/html'
return self.req.property_value('ui.default-text-format') == 'text/html'
return False
--- a/entity.py Wed Apr 15 14:07:30 2009 +0200
+++ b/entity.py Wed Apr 15 14:41:06 2009 +0200
@@ -398,7 +398,7 @@
needcheck = False
return mainattr, needcheck
- def attribute_metadata(self, attr, metadata):
+ def attr_metadata(self, attr, metadata):
"""return a metadata for an attribute (None if unspecified)"""
value = getattr(self, '%s_%s' % (attr, metadata), None)
if value is None and metadata == 'encoding':
@@ -425,14 +425,14 @@
# description...
if props.get('internationalizable'):
value = self.req._(value)
- attrformat = self.attribute_metadata(attr, 'format')
+ attrformat = self.attr_metadata(attr, 'format')
if attrformat:
return self.mtc_transform(value, attrformat, format,
self.req.encoding)
elif attrtype == 'Bytes':
- attrformat = self.attribute_metadata(attr, 'format')
+ attrformat = self.attr_metadata(attr, 'format')
if attrformat:
- encoding = self.attribute_metadata(attr, 'encoding')
+ encoding = self.attr_metadata(attr, 'encoding')
return self.mtc_transform(value.getvalue(), attrformat, format,
encoding)
return u''
--- a/web/form.py Wed Apr 15 14:07:30 2009 +0200
+++ b/web/form.py Wed Apr 15 14:41:06 2009 +0200
@@ -486,14 +486,14 @@
entity = self.edited_entity
if field.eidparam and entity.e_schema.has_metadata(field.name, 'format') and (
entity.has_eid() or '%s_format' % field.name in entity):
- return self.edited_entity.attribute_metadata(field.name, 'format')
+ return self.edited_entity.attr_metadata(field.name, 'format')
return self.req.property_value('ui.default-text-format')
def form_field_encoding(self, field):
entity = self.edited_entity
if field.eidparam and entity.e_schema.has_metadata(field.name, 'encoding') and (
entity.has_eid() or '%s_encoding' % field.name in entity):
- return self.edited_entity.attribute_metadata(field.name, 'encoding')
+ return self.edited_entity.attr_metadata(field.name, 'encoding')
return super(EntityFieldsForm, self).form_field_encoding(field)
def form_field_error(self, field):
--- a/web/views/editcontroller.py Wed Apr 15 14:07:30 2009 +0200
+++ b/web/views/editcontroller.py Wed Apr 15 14:41:06 2009 +0200
@@ -205,7 +205,8 @@
# submitted, since it will think the attribute is not modified
elif isinstance(value, unicode):
# file modified using a text widget
- value = Binary(value.encode(entity.attribute_metadata(attr, 'encoding')))
+ encoding = entity.attr_metadata(attr, 'encoding')
+ value = Binary(value.encode(encoding))
else:
# (filename, mimetype, stream)
val = Binary(value[2].read())
--- a/web/widgets.py Wed Apr 15 14:07:30 2009 +0200
+++ b/web/widgets.py Wed Apr 15 14:41:06 2009 +0200
@@ -409,7 +409,7 @@
entity.req.fckeditor_config()
if with_format:
if entity.has_eid():
- format = entity.attribute_metadata(self.name, 'format')
+ format = entity.attr_metadata(self.name, 'format')
else:
format = ''
frname = eid_param(self.name + '_format', entity.eid)
@@ -513,14 +513,14 @@
def _edit_render(self, entity):
wdgs = [self._file_wdg(entity)]
- if entity.attribute_metadata(self.name, 'format') in ('text/plain', 'text/html', 'text/rest'):
+ if entity.attr_metadata(self.name, 'format') in ('text/plain', 'text/html', 'text/rest'):
msg = self._edit_msg(entity)
wdgs.append(u'<p><b>%s</b></p>' % msg)
twdg = TextWidget(self.vreg, self.subjtype, self.rschema, self.objtype)
twdg.rname = self.rname
data = getattr(entity, self.name)
if data:
- encoding = entity.attribute_metadata(self.name, 'encoding')
+ encoding = entity.attr_metadata(self.name, 'encoding')
try:
entity[self.name] = unicode(data.getvalue(), encoding)
except UnicodeError: