Commits

Gael Pasgrimaud committed 4d844f3

use @property

Comments (0)

Files changed (6)

formalchemy/base.py

             self._fields = OrderedDict(items)
 
 
+    @property
     def render_fields(self):
         """
         The set of attributes that will be rendered, as a (ordered)
         if not self._render_fields:
             self._render_fields = OrderedDict([(field.key, field) for field in self._get_fields()])
         return self._render_fields
-    render_fields = property(render_fields)
 
     def configure(self, pk=False, exclude=[], include=[], options=[]):
         """

formalchemy/exceptions.py

 class ValidationError(Exception):
     """an exception raised when the validation failed
     """
+    @property
     def message(self):
         return self.args[0]
-    message = property(message)
     def __repr__(self):
         return 'ValidationError(%r,)' % self.message
 

formalchemy/ext/couchdb.py

             kwargs['multiple'] = True
         BaseField.__init__(self, *args, **kwargs)
 
+    @property
     def value(self):
         if not self.is_readonly() and self.parent.data is not None:
             v = self._deserialize()
                 return v
         value = getattr(self.model, self.name)
         return _stringify(value)
-    value = property(value)
 
+    @property
     def raw_value(self):
         try:
             value = getattr(self.model, self.name)
         if callable(self._value):
             return self._value(self.model)
         return self._value
-    raw_value = property(raw_value)
 
     def sync(self):
         """Set the attribute's value in `model` to the value given in `data`"""

formalchemy/ext/rdf.py

 class Field(BaseField):
     """"""
 
+    @property
     def value(self):
         if not self.is_readonly() and self.parent.data is not None:
             v = self._deserialize()
             if v is not None:
                 return v
         return getattr(self.model, self.name)
-    value = property(value)
 
+    @property
     def model_value(self):
         return getattr(self.model, self.name)
-    model_value = property(model_value)
     raw_value = model_value
 
     def sync(self):

formalchemy/ext/zope/__init__.py

                 options = [(term.title, term.value) for term in sourcelist]
         return BaseField.set(self, options=options, **kwargs)
 
+    @property
     def value(self):
         if not self.is_readonly() and self.parent.data is not None:
             v = self._deserialize()
             if v is not None:
                 return v
         return getattr(self.model, self.name)
-    value = property(value)
 
+    @property
     def raw_value(self):
         try:
             return getattr(self.model, self.name)
         if callable(self._value):
             return self._value(self.model)
         return self._value
-    raw_value = property(raw_value)
 
     def _validate(self):
         if self.is_readonly():

formalchemy/forms.py

                 success = False
         return success
 
+    @property
     def errors(self):
         """
         A dictionary of validation failures.  Always empty before `validate()` is run.
         errors.update(dict([(field, field.errors)
                             for field in self.render_fields.itervalues() if field.errors]))
         return errors
-    errors = property(errors)
 
     def __repr__(self):
         _fields = self._fields