Using http://www.pylonshq.com/download/1.0/go-pylons.py

python go-pylons.py tw10
cd tw10
source bin/activate
paster create -t pylons twform

(answered True for Mako, False for SQLAlchemy)

easy_install ToscaWidgets
easy_install tw.forms

cd twform
(modified development.ini to use port 8080 and the IP address 0.0.0.0
for this installation)
cd twform
vi config/middleware.py

(diff for middleware.py)

--- middleware.py.orig  2010-08-20 21:29:41.670605714 -0400
+++ middleware.py       2010-08-20 21:30:36.534034754 -0400
@@ -9,6 +9,7 @@
 from routes.middleware import RoutesMiddleware

 from twform.config.environment import load_environment
+import tw.api as twa

 def make_app(global_conf, full_stack=True, static_files=True,
**app_conf):
     """Create a Pylons WSGI application and return it
@@ -44,6 +45,10 @@
     app = SessionMiddleware(app, config)

     # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
+    app = twa.make_middleware(app, {
+        'toscawidgets.framework': 'pylons',
+        'toscawidgets.framework.default_view': 'mako',
+    })

     if asbool(full_stack):
         # Handle Python exceptions

to lib/helpers.py added:

from webhelpers.html import escape, HTML, literal, url_escape

controllers/test.py

from pylons import request, response, session, tmpl_context, config
from pylons.controllers.util import abort, redirect

from twform.lib.base import BaseController, render

import tw.forms as twf

movie_form = twf.TableForm('movie_form', action='save_movie',
children=[
    twf.HiddenField('id'),
    twf.TextField('title'),
    twf.TextField('year', size=4),
    twf.CalendarDatePicker('release_date'),
    twf.SingleSelectField('genera', options=['', 'Action', 'Comedy',
'Other']),
    twf.TextArea('description'),
])

class TestController(BaseController):

    def index(self):
        tmpl_context.movie_form = movie_form
        tmpl_context.value = {'title':'test'}
        return render('/index.mako')

templates/index.mako:

${h.literal(tmpl_context.movie_form(value=tmpl_context.value))}

This is using the documentation provided at:

http://toscawidgets.org/documentation/tw.forms/tutorials/index.html

While tw.dynforms does use Genshi, it does this only within its
forms.  If you've gotten this far, I'll find my notes on tw.dynforms
and test it against the virtualenv setup created above.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to