-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10 Feb 2009, at 14:12, Paul Johnston wrote:

> Now, I thought I had done a neat TW with Pylons tutorial...
>
> http://toscawidgets.org/documentation/ToscaWidgets/install/pylons_app.html

It's looking pretty good.

> But it doesn't quite work! Can someone have a look please and show me
> where I went wrong. Thanks,


I've had success following this scheme in the controller action:

> def index(self):
>     c.w = WidgetBunch()
>     c.w.form = new_user_form
>     c.action = h.url_for(action='update')
>     return render_mako('dashboard/page.mak')

where 'c' is the template context dictionary. I suspect that the  
problem is a missing WidgetBunch instantiation and no binding of the  
form object to the WidgetBunch's 'form' attribute.

Unless, of course, the codebase has changed and another approach is  
now favoured, I'm a little out of touch with tw changes.

Also, choosing a different example might make life easier all round.

The sample AddUser form makes use of the AddressFieldSet, which  
includes a PostalCode ...

> class AddressFieldset(ListFieldSet):
>     class fields(WidgetsList):
>         street = TextField(validator=UnicodeString)
>         number = TextField(validator=Int, size=4)
>         zip_code = TextField(validator=PostalCode())
>         state = TextField(default='NY',validator=StateProvince())
>
>     validator = FilteringSchema

which requires this import from formencode.national

> from formencode.national import USPostalCode as PostalCode, \
>                                 USStateProvince as StateProvince

which, in turn carries a warning if "pycountry" is not available:

> try:
>     import pycountry
>     has_pycountry = True
> except:
>     has_pycountry = False
> try:
>     from turbogears.i18n import format as tgformat
>     has_turbogears = True
> except:
>     has_turbogears = False
>
> no_country = False
> if not (has_pycountry or has_turbogears):
>     import warnings
>     no_country = ('Please easy_install pycountry or validators  
> handling '
>                   'country names and/or languages will not work.')

and pycountry carries the killer punch ...

> install_requires=['lxml'],

I wasn't aware that tw is now partly dependent on lxml.

That seems a lot of dependency to satisfy merely for an example.

tw.forms.samples is throwing an exception when trying to import  
PostalCode under Python 2.6 but it seems to be fine under Python 2.5.


Cheers,

Graham



-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkmSwtYACgkQOsmLt1NhivwBVQCfc5NtPFG3eNiYAZWwpA5zyLJh
0cMAoL4t15oOM0qeBwLYKeHDTsC+hHvWiQCVAgUBSZLC1lnrWVZ7aXD1AQINhgQA
wuRaKyF8ZOhM9AWO7ItmPxPgJpva9wtSSO9JsZ7hZW0pCyu6uEP8SCJKPuKQjgFL
IZ0A7k4aL3H5RUhSx9uOQa9EdnBTOGp9i35WJSQAfXTfJR+6Zfzgr7dA7+VswIWc
ms3USyFE1XxXXT6/cqTkwV5zdwWdXB3DyqkjLcZ8FZk=
=v/PS
-----END PGP SIGNATURE-----


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to