Gael Pasgrimaud avatar Gael Pasgrimaud committed 31292af Merge

merge

Comments (0)

Files changed (4)

formalchemy/base.py

         if args:
             for field in args:
                 if isinstance(field, basestring):
-                    field = getattr(_fields, field)
-                assert isinstance(field, fields.AbstractField)
+                    if field in _fields:
+                        field = _fields.get(field)
+                    else:
+                        raise AttributeError('%r as not field named %s' % (self, field))
+                assert isinstance(field, fields.AbstractField), field
                 field.bind(mr)
                 _new_fields.append(field)
             mr._render_fields = OrderedDict([(field.key, field) for field in _new_fields])

formalchemy/ext/pylons/controller.py

         else:
             data = request.POST
 
-        fs = fs.bind(self.get_model(), data=data, session=self.Session())
+        try:
+            fs = fs.bind(data=data, session=self.Session())
+        except:
+            # non SA forms
+            fs = fs.bind(self.get_model(), data=data, session=self.Session())
         if fs.validate():
             fs.sync()
             self.sync(fs)
                     return ''
                 redirect(model_url(self.collection_name))
             else:
-                fs = self.get_fieldset(_pk(fs.model))
+                fs.rebind(fs.model, data=None)
                 return self.render(format=format, fs=fs)
         return self.render(format=format, fs=fs, action='new', id=None)
 

formalchemy/ext/zope/__init__.py

         self.readonly = False
         self.focus = True
         self._errors = []
+        self._bound_pk = None
+        self.data = None
         self.validator = None
         self.iface = model
         focus = True
             try:
                 self.data = SimpleMultiDict(data)
             except:
-                raise Exception('unsupported data object %s.  currently only dicts and Paste multidicts are supported' % self.data)
+                raise Exception('unsupported data object %s. currently only dicts and Paste multidicts are supported' % self.data)
 
 class Grid(BaseGrid, FieldSet):
     """Grid aware of zope schema. See :class:`formalchemy.tables.Grid` for full api."""

File contents unchanged.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.