Permalink
Browse files

merge from gustavofonseca/isisdm

  • Loading branch information...
1 parent ff267d2 commit d5d30871464b58498a727cd45c946a3566f3ae5e @gustavofonseca gustavofonseca committed May 31, 2011
Showing with 8 additions and 11 deletions.
  1. +6 −10 isis/model/mapper.py
  2. +2 −1 isis/model/tests/test_couchdb.py
View
@@ -169,16 +169,13 @@ class FileProperty(CheckedProperty):
def __set__(self, instance, value):
if not isinstance(value, dict):
raise TypeError('%r must be a dictionary' % self.name)
-
+
if 'filename' not in value:
try:
value['filename'] = value['fp'].name
except AttributeError:
raise TypeError('%r must be a file' % self.name)
-
- if 'fp' in value:
- value['md5'] = hashlib.md5(value['fp'].read()).hexdigest()
-
+
super(FileProperty, self).__set__(instance, value)
def _pystruct(self, instance, value):
@@ -187,8 +184,7 @@ def _pystruct(self, instance, value):
'''
if isinstance(value, dict):
serializable_value = {'uid':value['uid'],
- 'filename':value['filename'],
- 'md5':value['md5'],}
+ 'filename':value['filename'],}
return serializable_value
return value
@@ -287,12 +283,12 @@ def _pystruct(self, instance, value):
return value.items()
def _colander_schema(self, instance, value):
- subfield = colander.SchemaNode(colander.Mapping(), name=self.name,)
-
+ #option arg acts in each attribute
kwargs = {}
if not self.required:
kwargs.update({'missing':None})
+ subfield = colander.SchemaNode(colander.Mapping(), name=self.name)
for subkey in self.subkeys:
subfield.add(colander.SchemaNode(colander.String(), name=subkey, **kwargs))
@@ -339,7 +335,7 @@ def __set__(self, instance, value):
raise TypeError('%r value must be tuple or list')
try:
- composite_texts = tuple(CompositeTuple(dict(composite_text), self.subkeys) for composite_text in value)
+ composite_texts = tuple(CompositeField(dict(composite_text), self.subkeys) for composite_text in value)
except ValueError:
raise TypeError('%r value must be a list or tuple of key-value structures' % self.name)
@@ -22,7 +22,7 @@
>>> class BookWithAttachment(CouchdbDocument):
... title = TextProperty(required=True, validator=text_validator)
- ... authors = MultiCompositeTextProperty(required=False, subkeys='fl')
+ ... authors = MultiIsisCompositeTextProperty(required=False, subkeys='fl')
... cover = FileProperty()
...
@@ -91,6 +91,7 @@
from isis.model import CouchdbDocument
from isis.model import TextProperty, MultiTextProperty
from isis.model import CompositeTextProperty, MultiCompositeTextProperty, ReferenceProperty, FileProperty
+from isis.model import IsisCompositeTextProperty, MultiIsisCompositeTextProperty
from isis.model.couchdb import _attach_updated, _attach_exists
import couchdbkit

0 comments on commit d5d3087

Please sign in to comment.