[TurboGears] Re: localization of formencode error messages

2006-02-14 Thread Dan Jacob

I have discussed with Ian about the patch for handling localized error
messages in formencode. Basically you pass a gettext function in the
state parameter, which then translates the message, This would allow
the TG controller to pass the i18n gettext function to formencode. I
haven't had time to check the formencode SVN yet, but ask Ian about it.



[TurboGears] Re: localization of formencode error messages

2006-02-14 Thread Dan Jacob

No, you just pass the reference to the gettext function you want to use
(in this case, TG''s gettext or lazy_gettext).



[TurboGears] Large applications - best practices and tools

2006-02-06 Thread Dan Jacob

Thinking about the post
http://groups.google.com/group/turbogears/browse_frm/thread/726e85552d5de2fb/da2c493c19f0097c#da2c493c19f0097c

I was wondering, are there ideas about the best way to structure a
large application consisting of numerous modules (in the functional,
non-Python sense) ?

The current setup created by quickstart creates two basic Python files,
controllers.py and model.py. This is OK for very small apps, but larger
apps would have something like:

/controllers
root.py
news.py
events.py
/models
users.py
news.py
events.py
/forms
users.py
news.py
events.py
/templates
news/
 index.kid
 form.kid
/helpers
news.py...

or like this:

controllers.py - Root goes here, base Controller classes
model.py - base SQLObject classes, models used across app
forms.py - base form /widget classes
templates/
 index.kid - front page to app
news/
 controllers.py
 model.py
 forms.py
 templates/
  index.kid
  form.kid

One may debate which style is better, but it would be very helpful to
add tools to tg-admin that would create these modules with stub files
and templates. For example:

tg-admin makemodule news

would create a news/ package with all the needed files such as
controllers.py.



[TurboGears] Re: Growing a Project

2006-02-02 Thread Dan Jacob

You could do it like this:

controllers.py  Root goes here, import other controllers
model.py  your app-wide sqlobjects here, import other models
forms.py  base form classes / widgets for whole app, non-module
specific forms

news/
controllers.py
model.py
forms.py
forums/
controllers.py
model.py


One point is that you should (I think) import any models into your root
model.py so that they can be handled by tg-admin sql commands.

I'm not sure about templates; they may need to go in a single
directory, with subdirectories for each module.

As a side note, what would be really handy would be a tg-admin command
like this:

tg-admin createapp news

which would create the required subdirectories, stub files, templates
etc in the right places in your project.



[TurboGears] Re: RFC: Mapping _ to lazy_gettext everywhere.

2006-02-01 Thread Dan Jacob

Jonathan LaCour wrote:
  This is not a symbol (in the sense you mean, @ or $ in Perl and
  Ruby), it is a function called (or aliased) _.

 I know its not a symbol in the language sense, but it sure looks like
 one to the untrained eye (which was my point, that you apparently
 missed).

No, it's a function call, with the correct Python syntax, and a
shortcut used in many languages (see below).

 sarcasm
 Yes, thats exactly what I am saying.  Lets go back to C.  A C-based
 TurboGears would be amazing.
 /sarcasm

Now, there's a challenge !


 A project like TurboGears will attract lots of newbies to Python,
 potentially coming from PHP, or other such tools.  I am almost
 certain that the majority of these people will be confused by the
 _, what it means, and where it came from.  I just was trying to
 avoid this.

Uh huh. I quote from the PHP manual:

This function returns a translated string if one is found in the
translation table, or the submitted message if not found. You may use
the underscore character '_' as an alias to this function. :
http://fi2.php.net/manual/fi/function.gettext.php

 Understandable, as long as things don't start down a slippery slope!
 Ramming things into __builtins__ for the purposes of a shortcut just
 seems like a scary precedent to set.  But, its your decision to make,
 and you seem to agree that magic is generally bad, so I won't
 complain anymore :)

I agree with you that magic is not Pythonic and should be largely
avoided (that's actually why I prefer TG to Django or Rails). However
here we are following precedent in the standard Python gettext library,
replacing the install() function with one that uses our own version of
gettext for handling threaded, multi-user web applications.

Of course if you prefer to make your code clear on that point just
have:

from turbogears.i18n import gettext as _

at the start of your modules.



[TurboGears] Re: RFC: Mapping _ to lazy_gettext everywhere.

2006-02-01 Thread Dan Jacob



 This thread should die :)
+1 ;-)



[TurboGears] Re: JSON chokes on Decimal value

2006-01-27 Thread Dan Jacob

Sorry, it seems to be working fine now. Must have been an installation
issue.



[TurboGears] JSON chokes on Decimal value

2006-01-26 Thread Dan Jacob


class Member(SQLObject):
name = StringCol(length=45)
billing_rate = CurrencyCol()

@turbogears.expose(format=json)
def get_member_data(self, member_id):
   member = model.Member.get(member_id)
return dict(member=member)

Throws this error:
Traceback (most recent call last):
  File
c:\python24\lib\site-packages\cherrypy-2.2.0beta-py2.4.egg\cherrypy\_cph
ttptools.py, line 98, in _run
self.main()
  File
c:\python24\lib\site-packages\cherrypy-2.2.0beta-py2.4.egg\cherrypy\_cph
ttptools.py, line 246, in main
body = page_handler(*virtual_path, **self.params)
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\identity\conditions.py, line 279, in _wrapper
return fn( *args, **kw )
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\controllers.py, line 241, in newfunc
html, fragment, *args, **kw)
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\database.py, line 189, in run_with_transaction
retval = func(*args, **kw)
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\controllers.py, line 263, in _execute_func
return _process_output(tg_format, output, html, fragment)
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\controllers.py, line 63, in _process_output
output = view.render(output, tg_format,
template=template,fragment=fragment)

  File
c:\python24\lib\site-packages\turbogears-0.9a0dev_r579-py2.4.egg\turboge
ars\view.py, line 56, in render
return jsonify.encode(info)
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\jsonify.py, line 72, in encode
return _instance.encode(obj)
  File
c:\python24\lib\site-packages\simplejson-1.1-py2.4.egg\simplejson\encode
r.py, line 259, in encode
  File
c:\python24\lib\site-packages\simplejson-1.1-py2.4.egg\simplejson\encode
r.py, line 212, in _iterencode
  File
c:\python24\lib\site-packages\simplejson-1.1-py2.4.egg\simplejson\encode
r.py, line 185, in _iterencode_dict
  File
c:\python24\lib\site-packages\simplejson-1.1-py2.4.egg\simplejson\encode
r.py, line 220, in _iterencode
  File
c:\python24\lib\site-packages\simplejson-1.1-py2.4.egg\simplejson\encode
r.py, line 226, in _iterencode_default
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\jsonify.py, line 67, in default
return jsonify(obj)
  File string, line 5, in jsonify
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\identity\soprovider.py, line 264, in jsonify_user
result = jsonify_sqlobject( obj )
  File
c:\python24\lib\site-packages\TurboGears-0.9a0dev_r579-py2.4.egg\turboge
ars\jsonify.py, line 50, in jsonify_sqlobject
result[name] = jsonify(getattr(obj, name))
  File string, line 5, in jsonify
  File
c:\python24\lib\site-packages\pyprotocols-1.0a0dev_r2082-py2.4-win32.egg
\dispatch\functions.py, line 244, in __getitem__
  File
c:\python24\lib\site-packages\pyprotocols-1.0a0dev_r2082-py2.4-win32.egg
\dispatch\interfaces.py, line 15, in __call__
NoApplicableMethods: ((Decimal(35.50),), {})



[TurboGears] Re: Standard WYSIWYG widget ?

2006-01-25 Thread Dan Jacob

What's the licencing for TinyMCE ?



[TurboGears] i18n no longer works for Kid templates

2006-01-25 Thread Dan Jacob

For some reason the config setting i18n.runTemplateFilter is no
longer read from the configuration file. I have tried the following,
neither of which work:

1) i18n.runTemplateFilter=True
2) kid.i18n.runTemplateFilter=True

I have added these settings to myproject/mypackage/config.py and
myproject/devcfg.py, but nether is found by cherrypy.config.



[TurboGears] Re: How to use widgets.FieldSet?

2006-01-25 Thread Dan Jacob

If you add to your dict_new widget=None it will work:

data_new = dict(
widget = None,
contrato_assinatura = '',
contrato_vencimento = '',
cliente_id = None,
nome_abreviado = None,
nome_completo = None,
contrato = None,
endereco = None,
cidade = None,

(widget being the default name of the fieldset). The problem is not
so much FieldSet itself but how to handle compound widgets within a
form with errors etc. (and what if you have a FieldSet within a
FieldSet ?)



[TurboGears] Re: How to use widgets.FieldSet?

2006-01-25 Thread Dan Jacob

BTW this is actually a separate issue. If the dict data_new misses any
of the fields you get the same KeyError; it should be the case that any
missing values are set to None or default.

Another point: to set the values of cidade, estado and cep, you
have to do this:

dict_new = dict(
widget = dict(
  cidade=Rio de Janeiro,
  estado=None,
  cep=None),...

(Does cidade mean city ? My Portuguese is almost non-existent ;-))

This is obviously inconvenient if you are passing in a SQLObject
instance, for example, as you have to break it down for each field set.

Perhaps instead of a field set widget we could have a separate FieldSet
class. For example:

my_form = TableForm(
  widgets = [TextField(name),
  TextField(country),
   TextField(postcode),
TextField(street)],
   fieldsets = [FieldSet(address), widgets = [country,
postcode, street]))

The FieldSet class merely handles layout; it does not do any error or
other form handling and is not a Widget subclass. It has an optional
template parameter. You can pass in a widget list and optionally a
fieldset list, if you want to have nested fieldsets. When the form is
rendered it renders the fieldsets somehow in the correct order.

This FieldSet class would allow you to create complex form layouts but
keep the form handling simple.



[TurboGears] Re: i18n no longer works for Kid templates

2006-01-25 Thread Dan Jacob

For some reason it is being dropped from cherrypy.config, but I can't
see where. In my start-project.py file I have:

print cherrypy.config.get(i18n.runTemplateFilter)

which displays True. I added the same line to turbogears/view.py (just
before the template engine is initialized):

engines = dict()
config = cherrypy.config
print cherrypy.config.get(i18n.runTemplateFilter)
engine_options = {...

which displays None. Why are some settings being dropped and where ?



[TurboGears] Re: i18n no longer works for Kid templates

2006-01-25 Thread Dan Jacob

OK I think I see the problem. In start-myproject.py you have:

import turbogears

before you have the config files loaded. Importing turbogears means
than view.py is imported, and the template engine parameters are set in
this module. So any Kid configuration options end up being ignored as
the engine(s) are already initialized by the time the config options
are read into cherrypy.

I fixed the problem in my local install by placing the engine setup
code into a function, _load_engines, which initializes the engines if
the engines dict is empty. This is called every time from
_choose_engine. I'll write a ticket for the trac when I have time.



[TurboGears] Re: problem with format_currency (ticket #445)

2006-01-24 Thread Dan Jacob


Jeff Watkins wrote:
 ${format_currency(2)} ==   2.00
 ${format_currency(20)} == 2,0.00
${format_currency(200)} ==2,00.00
   ${format_currency(2000)} ==   2,000.00
 ${format_currency(2)} == 2,000,0.00


I've added a fix to both format.py and test_i18n.py for this, so that a
better range of numbers are tested.

 Also, it doesn't add a dollar sign or whatever the appropriate
 monetary symbol is.

This is intentionally left out of format_currency - see the ticket.



[TurboGears] Standard WYSIWYG widget ?

2006-01-24 Thread Dan Jacob

Once the widget API has become a bit more stable I was thinking of
adding a standard WYSIWYG widget to TurboGears. Previous posts have
mentioned TinyMCE and others.Of course it must work well within TG,
including internationalization and licencing issues.

Is anyone using WYSIWG editors ? What are their personal favorites?



[TurboGears] Re: Jeremy Jones shifting gears

2006-01-23 Thread Dan Jacob

Very good point, and one that helps many projects outside of TurboGears
using the same components. We should only consider other components if
the maintainers are uncooperative about changes.



[TurboGears] Re: Jeremy Jones shifting gears

2006-01-22 Thread Dan Jacob

It seems the problems are not so much in TurboGears itself but with the
underlying components - CherryPy in particular recently (see Ian
Bicking's comment at http://blog.ianbicking.org/my-cherrypy-rant.html).
The problem we have is that although we can control the quality of TG
code, we can't control what goes on elsewhere. For example, us poor
benighted Windows users haven't had a functioning Toolbox until
recently, all because of Kid (and that's only fixed in the SVN, not
stable Kid release). I have wanted to add proper localization support
to form validation, but that will have to wait until it's in
FormEncode(for example, it does not seem to support unicode message
strings, which means even lazy_gettext won't work for customizing
messages).

The question is: how can we guarantee a stable TurboGears platform even
post 1.0 (or for that matter, 2.0) if we cannot guarantee the stability
of the underlying components ? Should we enforce a comply or die
attitude to other projects (if you don't fix your issues, we'll go to
Quixote/Cheetah/whatever) ? I don't think that's very workable, and TG
is having a positive rising tide lifts all boats effect on other
projects, but still we are often hamstrung by what happens outside of
TG, something Rails and Django don't have to worry about.

Any ideas ?



[TurboGears] Re: stateful widgets

2006-01-19 Thread Dan Jacob

I can think of one possible case: you have a shopping cart form
consisting of a variable number of TextField widgets for the quantity
of each item in your form. Each widget requires the Int validator. How
would this be handled with stateless forms and widgets ?



[TurboGears] Re: admi18n does not save .po files with UTF-8 encoding

2006-01-19 Thread Dan Jacob

OK Max, I had a quick look last night. It's a really neat tool !

Just a couple of points:

1. I got an error when I ran tg-admin i18n scan because the locales
directory was not created. This should be created automatically if it
does not exist.

2. The error I pointed out above occurred because the .po file was not
saved using UTF-8 encoding. The codecs module should be used here to
enforce this.



[TurboGears] Re: admi18n does not save .po files with UTF-8 encoding

2006-01-19 Thread Dan Jacob

OK Max, I had a quick look last night. It's a really neat tool !

Just a couple of points:

1. I got an error when I ran tg-admin i18n scan because the locales
directory was not created. This should be created automatically if it
does not exist.

2. The error I pointed out above occurred because the .po file was not
saved using UTF-8 encoding. The codecs module should be used here to
enforce this.



[TurboGears] Re: Class-style form declaration

2006-01-19 Thread Dan Jacob

+1 for the SQLObject style of form declaration. I don't like the
fields class though; maybe you can have the option to set the name
attribute if needed.



[TurboGears] Re: Class-style form declaration

2006-01-19 Thread Dan Jacob

+1 for the SQLObject style of form declaration. I don't like the
fields class though; maybe you can have the option to set the name
attribute if needed.



[TurboGears] Re: DataGrid with dynamic columns

2006-01-18 Thread Dan Jacob

I was also wondering about dynamic forms; for example, you have a set
of text fields in a table, and the number of text fields depends on
some dynamic value. For example, a shopping cart with a text field for
the quantity of each item.

Perhaps one could create a DataGridForm widget ?



[TurboGears] Re: SelectField Widget Memory

2006-01-18 Thread Dan Jacob

Probably not, because it depends on what kind of values you want to
work with (sometimes integers, sometimes strings etc). However, it
should be documented.



[TurboGears] Static files no longer available

2006-01-17 Thread Dan Jacob

Getting the following error when trying to access static
files:Traceback (most recent call last):
  File
c:\python24\lib\site-packages\cherrypy-2.2.0beta-py2.4.egg\cherrypy\_cphttptools.py,
line 96, in _run
applyFilters('before_main')
  File
c:\python24\lib\site-packages\cherrypy-2.2.0beta-py2.4.egg\cherrypy\filters\__init__.py,
line 131, in applyFilters
method()
  File
c:\python24\lib\site-packages\cherrypy-2.2.0beta-py2.4.egg\cherrypy\filters\staticfilter.py,
line 53, in before_main
raise cherrypy.WrongConfigValue(msg)
WrongConfigValue: StaticFilter requires an absolute final path. Make
static_filter.dir, .file, or .root absolute.

If an absolute path is now required this would seem a backwards step,
as it makes the apps less portable from one server to another. Is this
just a temporary bug or shall I add it to the trac ?



[TurboGears] admi18n does not save .po files with UTF-8 encoding

2006-01-17 Thread Dan Jacob

I have noticed that when I have used the admi18n tool in the Toolbox
for creating message .po files I get the following kind of error in the
Kid templates:

UnicodeEncodeError: 'utf-8' codec can't encode characters in position
3-4: ordinal not in range(128)

However, if I create the message.po file manually, save it with UTF-8
encoding, and use the msgfmt.py script manually (in Windows under
python_dist/Tools/i18n) it works fine.



[TurboGears] Re: admi18n does not save .po files with UTF-8 encoding

2006-01-17 Thread Dan Jacob

OK I don' t think the problem is with admi18n. You just have to
remember to save your .po files with UTF-8 encoding, then it should
work fine.



[TurboGears] Re: SelectField Widget Memory

2006-01-17 Thread Dan Jacob

It's probably because the option key values are integers, and the
argument test in the save method will be a string.

Either change your option values 1, 2 etc or add FormEncode Int
validator to force an integer value.



[TurboGears] Re: admi18n does not save .po files with UTF-8 encoding

2006-01-17 Thread Dan Jacob

Sure Max, I´ll take a look when I have time.



[TurboGears] Re: built-in method title of str object at 0x009BA038 string in widget

2006-01-11 Thread Dan Jacob

It may be related to ticket #272.



[TurboGears] Quickstart should create a default create_db.py script

2006-01-11 Thread Dan Jacob

It would be really handy if quickstart made a create_db.py script.
This script would have all the required imports etc and the developer
is then free to add database and other initialization code, for example
default categories, admin user, etc. When running tg-admin sql create
this script would be run once all the tables have been created.



[TurboGears] Re: bug question on CheckBoxList?

2006-01-10 Thread Dan Jacob

The best way to do this is first of all to pass a function argument to
populate your options at runtime, and then provide the default:

def get_topics():
return (t.id, t.name) for t in Topic.select()

W.CheckBoxList(name='topics',options=get_topics,
validator=ForEach(convert_to_list=True))

In your controller method for example:

@turbogears.expose(template='myapp.templates.welcome')
def index(self, *args, **kw):
cherrypy.request.input_values={''topics':identity.user.topics}
return dict()



[TurboGears] Re: bug question on CheckBoxList?

2006-01-04 Thread Dan Jacob

Are you talking about how to create a list with certain items checked
by default ?



[TurboGears] Re: bug question on CheckBoxList?

2006-01-03 Thread Dan Jacob

The problem is that CherryPy will create a list only if there is more
than one item with the same name attribute. If not, then it will
create a single value. Of course a checkbox value is only included in
the form if the checkbox is checked.

The easy way round this is to use the formencode ForEach class:

from formencode.foreach import ForEach
from formencode import validators

W.CheckBoxList(name='topics',options=some_options,
validator=ForEach(convert_to_list=True))

In this case the ForEach validator should always create a list, however
many items there are.

This should really be a default validator for this class (or its base
class). I'll try some tests to see if this will work.



[TurboGears] Re: How can I validate a form with several variables being lists?

2006-01-03 Thread Dan Jacob

Try validators.Int() and validators.OneOf() instead of AsInt and InList
(warning-untested code):

ForEach(All(Int(), OneOf([1,2,3]))



[TurboGears] Re: Use STAN for widgets ?

2006-01-03 Thread Dan Jacob

I have been perhaps a little unfair with bugs as such, I was
referrring to for example the problem with using template strings with
custom widgets leading to reloading problems on WinXP in particular
which may have nothing to do with Kid as such.

However I do agree with Michael's point about using STAN code for
widget code that can be inserted into Kid templates at run time. That
would be a lot easier from a programmatic point of view.



[TurboGears] Use STAN for widgets ?

2006-01-02 Thread Dan Jacob

Looking at thread
http://groups.google.com/group/turbogears/browse_frm/thread/b12609be62408f9c
I was just thinking : would STAN be a better model for widgets ? STAN
seems much more suited for building HTML components than Kid, and it
would make it easier to extend classes and to drop into different
templating systems. Plus we could avoid the various bugs we have been
having with Kid templates and widgets. 

Any thoughts ?



[TurboGears] Re: Fieldset widget input method and form_errors

2005-12-30 Thread Dan Jacob

Yes, that should be the case.



[TurboGears] Re: Problem running tg-admin from latest version

2005-12-28 Thread Dan Jacob

Exactly the same error message:

Traceback (most recent call last):
  File stdin, line 1, in ?
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.p
y, line 503, in require
needed = self.resolve(parse_requirements(requirements))
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.p
y, line 483, in resolve
raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: cElementTree=1.0.2



[TurboGears] Re: CheckBox widget not holding a check?

2005-12-28 Thread Dan Jacob

Perhaps then the value attribute of a CheckBox should be set to 1
or True unless explicitly set otherwise in the attrs argument.



[TurboGears] Negative feedback

2005-12-28 Thread Dan Jacob

Just read the post http://lion.taoriver.net/?p=10 which gives some
quite negative feedback about TurboGears. I think he has some valid
points about documentation: it's perhaps given the impression that TG
is already very easy to get up and running even for (python/web app)
novices, and maybe some info (like standard template variables) needs
further explanation.

Of course TG is still bery much in its infancy, but is this something
that visitors to the site should be informed of ?



[TurboGears] Re: Problem running tg-admin from latest version

2005-12-28 Thread Dan Jacob

Well, I have elementtree-1.2.6-py2.4.egg, if that helps. The
easy_install.pth contains:

c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg
c:\documents and settings\dan jacob\my
documents\turbogears\setuptools-0.6a8-py2.4.egg
c:\python24\lib\site-packages\ruledispatch-0.5a0.dev_r2100-py2.4-win32.egg
c:\python24\lib\site-packages\pyprotocols-1.0a0dev_r2082-py2.4-win32.egg
c:\python24\lib\site-packages\formencode-0.4-py2.4.egg
c:\python24\lib\site-packages\elementtree-1.2.6-py2.4.egg
c:\python24\lib\site-packages\turbogears-0.9a0dev_r385-py2.4.egg

This is a clean install of both Python and TurboGears on a WinXP system.



[TurboGears] Re: Problem running tg-admin from latest version

2005-12-28 Thread Dan Jacob

OK, I got it running from the latest SVN version. I don't know the
reason for the original problem.

Thanks !



[TurboGears] Re: CheckBox widget not holding a check?

2005-12-27 Thread Dan Jacob

Try this:

widgets.CheckBox(name=some_checkbox, labeltext=Some Checkbox,
  validator=validators.Bool(), attrs={'value':'1'})



[TurboGears] Problem running tg-admin from latest version

2005-12-27 Thread Dan Jacob

I get the following message when running tg-admin quickstart
projectname:

Traceback (most recent call last):
  File C:\Python24\Scripts\tg-admin-script.py, line 5, in ?
from pkg_resources import load_entry_point
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resour
y, line 2192, in ?
working_set.require(__requires__)
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resour
y, line 503, in require
needed = self.resolve(parse_requirements(requirements))
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resour
y, line 483, in resolve
raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: cElementTree=1.0.2



[TurboGears] Re: CheckBox widget not holding a check?

2005-12-27 Thread Dan Jacob

Sorry, explanation required:
The code compares the value attribute of the widget with the input
value. As the input value is None, and you have not specified the
attribute value, this is also None. Therefore the checked attribute
is inserted. The Bool validator returns True or False, neither of which
equal None and therefore the attribute checked is missing. Therefore
always set the value attribute to an explicit value.

I know this is not clear or documented, and it would be better to have
a value argument in the constructor or somesuch.



[TurboGears] Re: Problem running tg-admin from latest version

2005-12-27 Thread Dan Jacob

In reply to both Elvelind and Karl : yes and yes.



[TurboGears] Re: next up: forms/widgets talk and tickets

2005-12-24 Thread Dan Jacob

I added a lazy_gettext function in the other week which should handle
that. For example:
from turbogears.i18n import lazy_gettext
v=validators.MinLength(minLength=3,
messages={'tooShort':lazy_gettext('Enter at least %(minLength)i
characters')})

The lazy_gettext function calls gettext only when the message is being
converted to a string or string substitution is taking place. This
means you can mark strings for translation before the user locale is
known. This is useful for form encode error messages and form widget
labels, for example, which are declared in advance.



[TurboGears] tg-admin broken on Windows

2005-12-21 Thread Dan Jacob

When running any tg-admin command:

TurboGears 0.9a0dev-r1 command line interface

Usage: C:\Python24\Scripts\tg-admin-script.py [command] [options]

Available commands:
Traceback (most recent call last):
  File C:\Python24\Scripts\tg-admin-script.py, line 7, in ?
sys.exit(
  File c:\turbogears\turbogears\command\base.py, line 230, in main
longest = max([len(key) for key in commands.keys()])
ValueError: max() arg is an empty sequence



[TurboGears] New widgets added + some changes

2005-12-20 Thread Dan Jacob

I have added some new widgets to the collection:
PasswordField
ImageField
ButtonField
RadioButton
CheckBox
RadioButtonList
CheckBoxList

In addition, I have made a couple of modifications to the SelectField:
1. The options parameter takes a list of tuples(value, text, attrs)
or a function that returns same.
2. The selected attribute is set automatically based on input
value(s).

The CheckBoxList and RadioButtonList work the same way, with the
checked attribute set automatically.

For example:

s = SelectField(categoryID, options=[(XML, XML Document, {}),
(HTML, HTML Document, {})])

If the selected option is XML then the output is:
select name=categoryID
option value=XML selectedXML document/option
option value=HTMLHTML document/option
/select

Alternatively:

def get_categories():
return [(cat.id, cat.name, {'onclick':alert('%s') %cat.name}) for
cat in
   model.Category.select()]

s = SelectField(categoryID, options=get_categories)
c = CheckBoxList(categories, options=get_categories)

This is handy in situations where the options have to be generated
dynamically during template insertion for example.



[TurboGears] view.lookupTemplate prevents custom templates

2005-12-20 Thread Dan Jacob

When I add a custom template in a constructor I get the following
error:

my_template=
form xmlns:py=http://purl.org/kid/ns#; name=${widget.name}
  action=${getattr(self, 'action', None)} method=${getattr(self,
'method', 'post')}
  enctype=${getattr(self, 'enctype', None)}
div py:for=widget in widgets py:if=widget.hidden
py:strip=True
   ${widget.insert(getattr(self.widget_value, widget.name, None),
input_values, widget_error.get(widget.name, None))}
/div
table border=0
tr py:for=widget in widgets py:if=not widget.hidden
td
span py:if=widget.label and widget.labeltext

py:replace=widget.label.insert(widget.labeltext)/
span py:if=not widget.label or not widget.labeltext
py:strip=True#160;/span
/td
td${widget.insert(getattr(self.widget_value, widget.name,
None), input_values, widget_error.get(widget.name, None))}/td
/tr
 tr
td#160;/td
td${submit.insert(submittext)}/td
/tr
/table
/form


my_form=TableForm(widgets=[...], template=my_template)

Error:

Traceback (most recent call last):
  File
c:\python24\lib\site-packages\CherryPy-2.1.0-py2.4.egg\cherrypy\_cphttptools.py,
line 271, in run
main()
  File
c:\python24\lib\site-packages\CherryPy-2.1.0-py2.4.egg\cherrypy\_cphttptools.py,
line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)
  File c:\turbogears\turbogears\controllers.py, line 196, in newfunc
html, *args, **kw)
  File c:\turbogears\turbogears\database.py, line 174, in
run_with_transaction
retval = func(*args, **kw)
  File c:\turbogears\turbogears\controllers.py, line 225, in
_execute_func
return _process_output(tg_format, output, html)
  File c:\turbogears\turbogears\controllers.py, line 60, in
_process_output
output = view.render(output, tg_format, template=template)
  File c:\turbogears\turbogears\view.py, line 107, in render
return t.serialize(encoding=defaultencoding, output=format,
fragment=fragment)
  File
c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\__init__.py, line
232, in serialize
return serializer.serialize(self, encoding, fragment)
  File
c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\serialization.py,
line 51, in serialize
text = list(self.generate(stream, encoding, fragment))
  File
c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\serialization.py,
line 319, in generate
for ev, item in self.apply_filters(stream):
  File
c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\serialization.py,
line 77, in balancing_filter
for ev, item in stream:
  File c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\pull.py,
line 203, in _coalesce
for ev, item in stream:
  File c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\filter.py,
line 21, in transform_filter
for ev, item in apply_matches(stream, template, templates,
apply_func):
  File c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\filter.py,
line 31, in apply_matches
item = stream.expand()
  File c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\pull.py,
line 95, in expand
for ev, item in self._iter:
  File c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\pull.py,
line 164, in _track
for p in stream:
  File c:\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\pull.py,
line 203, in _coalesce
for ev, item in stream:
  File C:\projects\xmlvalidator\xmlvalidator\templates\index.py, line
74, in _pull
  File c:\turbogears\turbogears\widgets\base.py, line 111, in insert
self.template)
  File c:\turbogears\turbogears\view.py, line 113, in transform
tclass = lookupTemplate(template)
  File c:\turbogears\turbogears\view.py, line 62, in lookupTemplate
tfile = pkg_resources.resource_filename(package, %s.kid %
basename)
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.py,
line 676, in resource_filename
return get_provider(package_or_requirement).get_resource_filename(
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.py,
line 119, in get_provider
__import__(moduleOrReq)
ImportError: No module named
form xmlns:py=http://purl.org/kid/ns#; name=${widget.name}
  action=${getattr(self, 'action', None)} method=${getattr(self,
'method', 'post')}
  enctype=${getattr(self, 'enctype', N



[TurboGears] Re: New widgets added + some changes

2005-12-20 Thread Dan Jacob

The selected attribute is set if the option value is equal to the
input value, or is in the input value is that is a list (if you have a
number of form params with the same name, cherrypy will convert these
values to a list). Therefore you can handle both multiple and single
select values. To preselect these values, of course, just use the
default in the constructor.

s = SelectField(categoryID, options=[(XML, XML Document, {}),
(HTML, HTML Document, {})], attrs=dict(multiple=multiple),
default=[HTML, XML])

Both XML and HTML are now selected. If the form input is HTML
then only HTML will be selected.

In XHTML, of course, the key/value pair is selected=selected. This is
output as 'selected' in HTML 4.0.



[TurboGears] Widgets and client-side validation

2005-12-20 Thread Dan Jacob

What are people's thoughts on adding automatic JavaScript validation to
widgets ? There are two possibilities here:

1. The old-fashioned way. Basically alert boxes are used to display
error messages (though other methods are possible). Basically we would
need to translate all the FormEncode validators to JavaScript somehow.

2. The AJAX way. The validation is done server-side, and the error
messages are sent back with JSON and rendered in the form somehow. This
would be neat but is it possible to prevent the same form being sent
twice to the server (once for validation, then again for execution)



[TurboGears] Re: Widgets and client-side validation

2005-12-20 Thread Dan Jacob

Yes that's what I meant. Basically each FormEncode validator has a
matching JavaScript validator (if possible or practical). Setting the
validator in the widget will automatically add some JavaScript when the
widget is rendered, or alternatively a single JavaScript function is
created for the whole form.

The JSON validation thing would be neat if it could work. Any ideas on
that ?



[TurboGears] Re: 4 new widgets; attrs now supported

2005-12-19 Thread Dan Jacob

I've just finished writing and testing some new widgets, including a
RadioButtonList and Checkbox list. One thing came to mind with these
widgets and the SelectField widgets:the option list may need to be
created dynamically (e.g. during template insertion). I thought it
would be a good idea for the options argument to be either a list of
tuples(value, text, optional attrs) or a function returning same:

def get_categories():
return [(cat.id, cat.name) for cat in model.Category.select()]

s = SelectField(categoryID, labeltext=Choose a category,
options=get_categories, validator=IntValidator())

c = CheckBoxList(categories, options=get_categories,
validator=ForEach(IntValidator()))

The selected or checked attributes are automatically set if they
match the input value(s).



[TurboGears] Making form handling and widgets work

2005-12-16 Thread Dan Jacob

I've been following the discussions about form handling and widgets
lately and I think it would be fantastic if we get this aspect of
TurboGears working right. At present it is very awkward to handle forms
and widgets are difficult to use and extend. I also think if we get
this aspect of TG right we will be well on the way to a Rails-and
-Django beating framework (feature for feature).

Could people summarize here what they think would be needed to get TG
forms and widgets up to scratch ?

Here's my Christmas list:

1. An error_handler argument to @turbogears.expose. This would simplify
code like this:

@turbogears.expose(html=templates.form)
def add(self):
 return dict(form=article_form())

@turbogears.expose(inputform=article_form())
def create(self, title, maintext, categoryID, **kw):
 if cherrypy.request.form_errors:return self.add
 # rest of function:add an article and redirect

to this:

@turbogears.expose(html=templates.form)
def add(self):
 return dict(form=article_form())

@turbogears.expose(inputform=article_form(), error_handler=add)
 # go straight to adding an article and redirect, no need to check
for errors

2. Functions to access cherrypy.request.form_errors and input_values to
save on typing, for example:

errors = turbogears.get_errors()
turbogears.set_defaults(article.toDict())

3. An attributes argument for widgets, for example:

TextField(name, default=Ok, attrs={'size':50, 'maxlength'100'})
- also for compound widgets if needed:

f = TableForm(attrs={'enctype':'multipart/form-data'},
widget_attrs={'name', {'size':50}})

4. A schema argument for Form widgets, so you can pass in a
FormEncode schema

5. Multiple submit buttons for Forms

6. Select and radio/checkbox group widgets which select/check values
automatically

7. Select and radio/checkbox group widgets populated automatically by
passing in a SQLObject SelectResult

8. Extended SQLObject class which populates results from form request
values. When you define a subclass you provide a __public__ list like
so:

class Article(TG_SQLObject):
__public__=[title, maintext, categoryID]
   title = StringCol(length=200)
   other fields
In your controller:

@turbogears.expose(..)
def create(self, **kw):
Article.autoCreate(author=identity.user)

@turbogears.expose(..)
def update(self, id, **kw):
   a = Article.get(id)
   a.autoUpdate(updated=datetime.now())

In both cases, the attributes title, maintext and categoryID are
automatically set if found in the cherrypy.request.paramMap, and
additional fields are then passed in as arguments. This is **sort of**
like Add/UpdateManipulators in Django.

9. A PSP and world peace :-)



[TurboGears] Widgets - difficult API

2005-12-14 Thread Dan Jacob

I've been trying to add new widgets to base.py and to my own test app,
and I've found it's unnecessarily difficult to customize/extend
existing widgets. For example:

1. I want to add a size attribute to a text field
2. I want the form to use enctype=multipart/form-data

In order to do these, I have to create a new template for that widget,
which totally defeats the object of using widgets - it's a lot easier
to just write the HTML in the template.

Quixote seems to have a much more instinctive way of handling this :
the attributes are passed in as keyword arguments. In TG it would work
like this:

text = TextField(mytext, default=OK, size=20)
form = TableForm(enctype=multipart/form-data)

Alternatively use a dictionary:

text = TextField(mytext, default=OK, attrs={'size':20})
form = TableForm(attrs={'enctype':'multipart/form-data'})

Either would make it a lot easier to both write and extend widgets,
instead of an inflexible template that has to be rewritten to do
anything useful.  You could then create for example a basic InputField
class like this:

class InputField(Widget):
template = div xmlns:py=http://purl.org/kid/ns#;input
type=$widget.input_type name=${widget.name} value=${widget_value}
py:attrs=$widget.attrs/
span class=error
py:if=widget_error${str(widget_error)}/span/div

and then:

class TextField(Widget):input_type=text
class PasswordField(Widget):input_type=password
class HiddenField(Widget):input_type=hidden
class FileField(Widget):input_type=file



[TurboGears] Re: Widgets - difficult API

2005-12-14 Thread Dan Jacob

Sorry, that should be:
class TextField(InputField):input_type=text
class PasswordField(InputField):input_type=password
class HiddenField(InputField):input_type=hidden
class FileField(InputField):input_type=file



[TurboGears] TG application - simple DTD validator

2005-12-12 Thread Dan Jacob

I have just finished a really simple TurboGears application for work
use - it validates XML documents with a DOCTYPE declaration. The PyXML
library is used for validating.

The address is http://www.xeepra.fi:8080. I can't promise it will be up
and running all the time, but give it a try !



[TurboGears] Changes to i18n package

2005-12-09 Thread Dan Jacob

I've made a few changes to the i18n package:

1. I've decided to dump all those XML files and replace them with
Python modules. For example, the formatting settings for Danish are now
in turbogears/i18n/data/da.py instead of turbogears/i18n/da.xml.
Basically I generated the Python modules from the data in the XML
files. This should be a lot more efficient.

2. There's a new function in turbogears.i18n.utils,
google_translate(from_lang, to_lang, text). It basically queries the
Google Translation Service page and screen-scrapes the text to give you
a translation. For example:

h2${google_translate(en, es, Are you ready to Gear Up?)}/h2

will return you a Spanish translation. At present the service supports
translation to and from English, Spanish, Italian, German, Chinese,
Japanese, Portuguese and Korean.

3. There are some new number handling functions for handling large
numbers and parsing number strings.

In the meantime,  ¿Es usted listo engranar para arriba?



[TurboGears] JSON WriteException - long int

2005-12-01 Thread Dan Jacob

I have two model objects:

class Region(SQLObject):
name = StringCol(length=80)

class City(SQLObject):
name = StringCol(length=80)
region = ForeignKey(Region)

And a method in my controller class:

@turbogears.expose(format=json)
def get_cities(self, region):
 dict(cities=jsonify(model.City.selectBy(regionID=region)))

In my development server, I am using WinXP/SQLite3 and it works fine.
The production server uses Win2003/MySQL 4.0.8 and it fails, with the
following traceback:

2005/12/01 12:17:42  INFO Traceback (most recent call last):
  File
c:\python24\lib\site-packages\CherryPy-2.1.0-py2.4.egg\cherrypy\_cphttpt
ools.py, line 271, in run
main()
  File
c:\python24\lib\site-packages\CherryPy-2.1.0-py2.4.egg\cherrypy\_cphttpt
ools.py, line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)
  File d:\turbogears\turbogears\controllers.py, line 206, in newfunc
return controllers._process_output(tg_format, output, html)
  File d:\turbogears\turbogears\controllers.py, line 58, in
_process_output
output = view.render(output, tg_format, template=template)
  File d:\turbogears\turbogears\view.py, line 94, in render
return json.write(info)
  File c:\python24\lib\site-packages\json_py-3.2.1-py2.4.egg\json.py,
line 305
, in write
  File c:\python24\lib\site-packages\json_py-3.2.1-py2.4.egg\json.py,
line 253
, in write
  File c:\python24\lib\site-packages\json_py-3.2.1-py2.4.egg\json.py,
line 264
, in _write
  File c:\python24\lib\site-packages\json_py-3.2.1-py2.4.egg\json.py,
line 273
, in _write
  File c:\python24\lib\site-packages\json_py-3.2.1-py2.4.egg\json.py,
line 264
, in _write
  File c:\python24\lib\site-packages\json_py-3.2.1-py2.4.egg\json.py,
line 302
, in _write
WriteException: Cannot write in JSON: 1

I find that the only difference between the two versions is region ID:

SQLLite version:

[{'regionID': 3, 'id': 2, 'name': u'Imatra'}, {'regionID': 3, 'id': 3,
'name': u
'Joutseno'}, {'regionID': 3, 'id': 4, 'name': u'Lappeenranta'},
{'regionID': 3,
'id': 5, 'name': u'Lemi'}]

MySQL version:

[{'regionID': 3L, 'id': 2, 'name': u'Imatra'}, {'regionID': 3L, 'id':
3, 'name': u
'Joutseno'}, {'regionID': 3L, 'id': 4, 'name': u'Lappeenranta'},
{'regionID': 3L,
'id': 5, 'name': u'Lemi'}]

Json therefore chokes on long integer values, which are returned from
MySQLdb/SQLObject for foreign key values.



[TurboGears] Re: JSON WriteException - long int

2005-12-01 Thread Dan Jacob

PS the latest version of json-py on sourceforge corrects the bug but
the version in json_py-3.2.1-py2.4.egg was buggy.



[TurboGears] Re: How to make turbogears.url answering something other than localhost:8080

2005-12-01 Thread Dan Jacob

Try cherrypy baseURLFilter:

baseUrlFilter.on=True
baseUrlFilter.baseUrl = http://mysite.com;

This will set the cherrypy.request.base property to
http://mysite.com;. You can then call for example:

cherrypy.HTTPRedirect (cherrypy.request.base + '/relative_url')

You can also use the turbogears.url function, which I believe
automatically prefixes URLs with the base.



[TurboGears] Re: How to make turbogears.url answering something other than localhost:8080

2005-12-01 Thread Dan Jacob

Try the baseURLFilter:

baseUrlFilter.on=True
baseUrlFilter.baseUrl = http://my.site.com;

cherrypy.HTTPRedirect(turbogears.url(/relative_url/)) should then
work.



[TurboGears] Re: problem with kid py:match

2005-11-30 Thread Dan Jacob

Remove xmlns=http://www.w3.org/1999/xhtml; from the html tag.



[TurboGears] Re: Widgets: how-to?

2005-11-30 Thread Dan Jacob

Try:

div py:replace=weekgrid.insert() /



[TurboGears] Re: ForeignKey to User class from identity package

2005-11-25 Thread Dan Jacob

Tim Lesher wrote:
 On 11/20/05, Patrick Lewis [EMAIL PROTECTED] wrote:
  While this appears to work, as soon as you try to reference
  Bar.foo_obj, an exception is thrown.
 
  Traceback (most recent call last):
File console, line 1, in ?
File string, line 1, in lambda
  AttributeError: 'Bar' object has no attribute '_SO_class_foo'

 I see the same issue. It's interesting that if, in an interactive
 session, I import both models, then manually set Bar._SO_class_foo =
 Foo, everything works.

 I haven't figured out how to translate that into a strategy for TG yet.
 --
 Tim Lesher [EMAIL PROTECTED]

I've found the following works:
from sqlobject import *
from turbogears.identity.model import somodel

class Report(SQLObject):
 title = StringCol()
 user = ForeignKey(User)
  _SO_class_User = somodel.User



[TurboGears] Re: ForeignKey to User class from identity package

2005-11-25 Thread Dan Jacob

Further to what I just said:

This does not work with Catwalk, I get an alert saying Fail to get
reference to object User if I click on the Report table.

It seems that the most instinctive way would be to have user =
ForeignKey(turbogears.User) but we'll see how future versions of
SQLObject will resolve this.



[TurboGears] Suggestions for new stuff in stdvars

2005-11-20 Thread Dan Jacob

I was thinking of some useful functions/variables that could go into
stdvars

cycle(items, *args): generator that returns (index, item, looped_value)
like this:

tr py:for=index, product, css_class in std.cycle(products, 'row_0',
'row_1') py:attrs=class=css_class
   td.../td
/tr

produces:

tr class=row_0
tr class=row_1
tr class=row_0
etc.

errors: cherrypy.request.form_errors, or empty dict
inputs: cherrypy.request.form_inputs, or empty dict
require(permissions): returns True if current identity has
permission(s) e.g.

a py:if=std.require('edit_news') href=editEdit news item/a

if_error(name, if_error_str, if_not_error_str=None): if
cherrypt.request.form_errors has name  then return the error string,
if not return second string. Error string may be formatted with
%(error)s:

label py:attrs=class=std.if_error('title', 'error')Title
${std.if_error('title', ': %(error)s')}/label

On an error this may produce:

label class=errorTitle : please enter a value/label



[TurboGears] Re: problems with sql create now

2005-11-18 Thread Dan Jacob

Yes, I get the same error running tg-admin sql create:

Using database URI sqlite:///metsaporssi.db
Traceback (most recent call last):
  File C:\Python24\Scripts\tg-admin-script.py, line 7, in ?
sys.exit(
  File
c:\python24\lib\site-packages\turbogears-0.9a0dev_r223-py2.4.egg\turboge
ars\command\__init__.py, line 233, in main
command.run()
  File
c:\python24\lib\site-packages\turbogears-0.9a0dev_r223-py2.4.egg\turboge
ars\command\__init__.py, line 116, in run
command.the_runner.run(sys.argv)
  File
c:\python24\lib\site-packages\sqlobject-0.8dev_r1149-py2.4.egg\sqlobject
\manager\command.py, line 102, in run
runner.run()
  File
c:\python24\lib\site-packages\sqlobject-0.8dev_r1149-py2.4.egg\sqlobject
\manager\command.py, line 232, in run
self.load_options_from_egg(egg_spec)
  File
c:\python24\lib\site-packages\sqlobject-0.8dev_r1149-py2.4.egg\sqlobject
\manager\command.py, line 415, in load_options_from_egg
dist, conf = self.config_from_egg(egg_spec)
  File
c:\python24\lib\site-packages\sqlobject-0.8dev_r1149-py2.4.egg\sqlobject
\manager\command.py, line 425, in config_from_egg
pkg_resources.require(egg_spec)
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.p
y, line 503, in require
needed = self.resolve(parse_requirements(requirements))
  File
c:\python24\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.p
y, line 487, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (turbogears 0.9a0dev-r223
(c:\python24\lib\site-p
ackages\turbogears-0.9a0dev_r223-py2.4.egg),
Requirement.parse('TurboGears=0.9a
0'))

I've tried running easy_install, ez_setup.py -U setuptools, and
setup.py develop, all to no avail :-(



[TurboGears] Re: About LocalizedSubmitButton.

2005-11-17 Thread Dan Jacob

This is a good point. All widgets should be localized using _(). This
is only required for attributes, as the i18n_filter calls gettext on
all text in Kid templates(if the i18n.runTemplateFilter option is on).

BTW the LocalizedSubmitButton has been moved to i18n/widgets.py, along
with some example widget classes.



[TurboGears] i18n documentation

2005-11-17 Thread Dan Jacob

If posted some documentation at the trac wiki:

http://trac.turbogears.org/turbogears/wiki/Internationalization

Any comments are welcome!



[TurboGears] Schema errors not picked up in cherrypy.request.form_errors

2005-11-10 Thread Dan Jacob

When using a schema the form_errors variable in cherrypy.request is not
updated (version 0.9, latest version from subversion).

For example:

class TestSchema(formencode.schema):
description = validators.MinLength(3)

class Root:

   @turbogears.expose(validators=TestSchema())
   def update(self, description, has_errors=False):
   if has_errors:
 flash(cherrypy.request.form_errors['description'])
 raise HTTPRedirect, '/form'
   # rest of method

This returns a key error, as the cherrypy.request.form_errors dict is
empty.

The reason for this is line 190 in controllers.py:
errors = error.error_dict
This should read:
errors.update(error.error_dict)

so that the cherrypy.request.form_errors variable is filled with the
schema errors.



[TurboGears] Stdvars and form variables

2005-11-08 Thread Dan Jacob

Would it be possible to add the form variables
cherrypy.request.form_errors, cherrypy.request.input_values and
cherrypy.request.form_process to the stdvars ? Of course this can be
done with a function added to view.variableProviders but it would be
nice if this were standard.