Permalink
Browse files

Merge pull request #14 from cguardia/master

split simple example in two
  • Loading branch information...
2 parents a0713c5 + 42bb283 commit 9208a54c2c654dd65b63a5ce25e2f2bb92fd5817 @runyaga runyaga committed May 23, 2012
View
@@ -93,26 +93,25 @@ Dependencies:
* :py:mod:`ptah_crowd`
-simple
-======
+simple_forms
+============
-`simple` is different than the other examples. The `simple` folder is not
-a Python package but a collection of example modules. Each module is
-an example of a specific aspect of Ptah. The goal is to show, in isolation,
-a particular feature/function of Ptah.
+This directory contains two examples of form generation using Ptah's form
+library. The idea is to show how to generate forms using the two configuration
+approaches provided by the form library.
-These examples do not use ``pserve`` to run these examples. Just use the
-python environment you have installed ptah.
+These examples do not use ``pserve`` to run. Just use the python environment
+where you have installed ptah.
-Example of running on of the simple examples::
+Example of running one of the simple_forms examples::
- $ cd examples/simple
+ $ cd examples/simple_forms
$ /virtualenv/bin/python form_declarative.py
form_declarative.py
~~~~~~~~~~~~~~~~~~~
-Example of using :py:mod:`ptah.form` declartively. The form example subclasses
+Example of using :py:mod:`ptah.form` declaratively. The form example subclasses
:py:class:`ptah.form.Form` and has a validator.
.. literalinclude:: ../simple/form_declarative.py
@@ -127,12 +126,19 @@ fields are added manually.
.. literalinclude:: ../simple/form_imperative.py
:linenos:
-layout.py
-~~~~~~~~~
+
+simple_layout
+=============
Ptah provides a :py:mod:`pyramid.renderers` independent mechanism to provide
template composition (e.g. template inheritance). The :py:mod:`ptah_minicms`
provides an example of layout preview which draws borders around the layouts.
+This is a simple example of Ptah layouts, which shows how to define layouts and
+how to assign them to different parts of a site.
+
+layout.py
+~~~~~~~~~
+
.. literalinclude:: ../simple/layout.py
:linenos:
@@ -8,3 +8,4 @@ run examples
------------
/virtualenv/bin/python2.7 ./form_imperative.py
+/virtualenv/bin/python2.7 ./form_declarative.py
@@ -21,7 +21,7 @@ def redirect(request):
@view_config(
'test-form.html',
- wrapper=ptah.wrap_layout(),
+ renderer='__main__:templates/layout.pt',
context=DefaultRootFactory)
class MyForm(form.Form):
@@ -21,7 +21,7 @@ def redirect(request):
@view_config(
'test-form.html',
- wrapper=ptah.wrap_layout(),
+ renderer='__main__:templates/layout.pt',
context=DefaultRootFactory)
def form_view(context, request):
@@ -73,7 +73,8 @@ def update_action(form):
'description': 'Context description'}
# render form
- return myform()
+ myform.update()
+ return {'view': myform}
if __name__ == '__main__':
@@ -22,7 +22,7 @@
<div class="container">
${structure: view.render_messages()}
- ${structure: wrapped_content}
+ ${structure: view.render()}
</div>
</div>
</div>
View
@@ -0,0 +1,10 @@
+readthedocs
+------------
+
+You can read the `Examples` documentation on-line at
+`http://ptah-examples.readthedocs.org <http://ptah-examples.readthedocs.org/en/latest/index.html>`_.
+
+run examples
+------------
+
+/virtualenv/bin/python2.7 ./layout.py
File renamed without changes.

0 comments on commit 9208a54

Please sign in to comment.