has_metadata is a schema method tls-sprint
authorsylvain.thenault@logilab.fr
Thu, 12 Mar 2009 20:07:20 +0100
branchtls-sprint
changeset 1107 961a478593a5
parent 1104 58f27c3c0167
child 1108 1e5ed5f57f2f
has_metadata is a schema method
entities/__init__.py
web/form.py
web/views/editcontroller.py
web/widgets.py
--- a/entities/__init__.py	Thu Mar 12 19:58:58 2009 +0100
+++ b/entities/__init__.py	Thu Mar 12 20:07:20 2009 +0100
@@ -413,7 +413,7 @@
         """return True if fckeditor should be used to edit entity's attribute named
         `attr`, according to user preferences
         """
-        if self.req.use_fckeditor() and self.has_metadata(attr, 'format'):
+        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.req.property_value('ui.default-text-format') == 'text/html'
--- a/web/form.py	Thu Mar 12 19:58:58 2009 +0100
+++ b/web/form.py	Thu Mar 12 20:07:20 2009 +0100
@@ -475,14 +475,14 @@
     
     def form_field_format(self, field):
         entity = self.entity
-        if field.eidparam and entity.has_metadata(field.name, 'format') and (
+        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.entity.attribute_metadata(field.name, 'format')
         return self.req.property_value('ui.default-text-format')
 
     def form_field_encoding(self, field):
         entity = self.entity
-        if field.eidparam and entity.has_metadata(field.name, 'encoding') and (
+        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.entity.attribute_metadata(field.name, 'encoding')
         return super(EntityFieldsForm, self).form_field_encoding(field)
--- a/web/views/editcontroller.py	Thu Mar 12 19:58:58 2009 +0100
+++ b/web/views/editcontroller.py	Thu Mar 12 20:07:20 2009 +0100
@@ -213,7 +213,7 @@
                     value = None
                 else:
                     val.filename = value[0]
-                    if entity.has_metadata(attr, 'format'):
+                    if entity.e_schema.has_metadata(attr, 'format'):
                         key = '%s_format' % attr
                         formparams[key] = value[1]
                         self.relations.append('X %s_format %%(%s)s'
--- a/web/widgets.py	Thu Mar 12 19:58:58 2009 +0100
+++ b/web/widgets.py	Thu Mar 12 20:07:20 2009 +0100
@@ -419,7 +419,7 @@
                     frname, format, frname)
             return u'%s<textarea cubicweb:type="wysiwyg" onkeypress="autogrow(this)" name="%s" %s>%s</textarea>' % (
                 hidden, self.rname, self.format_attrs(), dvalue)
-        if with_format and entity.has_metadata(self.name, 'format'):
+        if with_format and entity.e_schema.has_metadata(self.name, 'format'):
             fmtwdg = entity.get_widget(self.name + '_format')
             fmtwdgstr = fmtwdg.edit_render(entity, tabindex=self.attrs['tabindex'])
             self.attrs['tabindex'] = entity.req.next_tabindex()
@@ -467,7 +467,8 @@
     def _file_wdg(self, entity):
         wdgs = [u'<input type="file" name="%s" %s/>' % (self.rname, self.format_attrs())]
         req = entity.req
-        if entity.has_metadata(self.name, 'format') or entity.has_metadata(self.name, 'encoding'):
+        if (entity.e_schema.has_metadata(self.name, 'format')
+            or entity.e_schema.has_metadata(self.name, 'encoding')):
             divid = '%s-%s-advanced' % (self.name, entity.eid)
             wdgs.append(u'<a href="%s" title="%s"><img src="%s" alt="%s"/></a>' %
                         (html_escape(toggle_action(divid)),