Commits

Anonymous committed 0cd168a Merge

Merged from https://bitbucket.org/ss1978/wtforms/. Thanks to ss1978 for contribution. Refs #48.

Comments (0)

Files changed (1)

wtforms/ext/appengine/fields.py

 import decimal
-
+import logging
 from wtforms import fields, widgets
 
 class ReferencePropertyField(fields.SelectFieldBase):
         if self._formdata is not None:
             for obj in self.query:
                 if str(obj.key()) == self._formdata:
-                    self._set_data(obj.key())
+                    self._set_data(obj)
                     break
         return self._data
 
 
         for obj in self.query:
             key = str(obj.key())
-            label = self.label_attr and getattr(obj, self.label_attr) or str(obj)
-            yield (key, label, key == self.data)
+            label = self.label_attr and getattr(obj, self.label_attr) or obj
+            yield (key, label, self.data and ( self.data.key( ) == obj.key() ) )
 
     def process_formdata(self, valuelist):
         if valuelist:
     def pre_validate(self, form):
         if not self.allow_blank or self.data is not None:
             for obj in self.query:
-                if str(self.data) == str(obj.key()):
+                if str(self.data.key()) == str(obj.key()):
                     break
             else:
                 raise ValueError(self.gettext(u'Not a valid choice'))