Commits

Anonymous committed f1e136e

peppercorn support

Comments (0)

Files changed (4)

pyramid_simpleform/form.py

 import colander
+import peppercorn
 
 
 class Form(object):
             else:
                 params = self.request.params
             
+        params = peppercorn.parse(params.items())
         self.data.update(params)
 
         if self.schema:

pyramid_simpleform/renderers.py

         """
         return HTML.tag("div", self.csrf(name), style="display:none;")
 
+    def __start__(self, value):
+        """
+        Renders peppercorn __start__ hidden tags with given values.
+
+        For example:
+
+        form.__start__('series:mapping')
+        >>> <input type="hidden" name="__start__" value="series:mapping" />
+
+        :versionadded: 0.5
+        """
+
+        return self.hidden('__start__', value)
+
+
+    def __end__(self):
+        """
+        Renders peppercorn __end__ hidden tag
+
+        For example:
+
+        form.__end__()
+        >>> <input type="hidden" name="__end__" />
+        """
+
+        return self.hidden('__end__')
+
     def hidden_tag(self, *names):
         """
         Convenience for printing all hidden fields in a form inside a 

pyramid_simpleform/tests.py

                 '<div style="display:none;"><input id="_csrf" name="_csrf" '
                 'type="hidden" value="csrft" /></div>')
 
+    def test_start(self):
 
- 
+        from pyramid_simpleform.form import Form
+        from pyramid_simpleform.renderers import FormRenderer
+
+        request = testing.DummyRequest()
+        form = Form(request, SimpleColanderSchema())
+        renderer = FormRenderer(form)
+
+        self.assert_(renderer.__start__('series:mapping') == \
+                '<input id="__start__" name="__start__" type="hidden" value="series:mapping" />')
+
+    def test_end(self):
+
+        from pyramid_simpleform.form import Form
+        from pyramid_simpleform.renderers import FormRenderer
+
+        request = testing.DummyRequest()
+        form = Form(request, SimpleColanderSchema())
+        renderer = FormRenderer(form)
+
+        self.assert_(renderer.__end__() == \
+                '<input id="__end__" name="__end__" type="hidden" />')
  
  
     def test_text(self):
     'webhelpers',
     'formencode',
     'colander',
+    'peppercorn',
 ]
 
     
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.