Hello to all.

I am new to this group and therefore i want to introduce myself.

I am a Developer working with Turbogears for over 2 years now.
The time before I directly used CherryPy and my "home made"
connections to SQL-Databases. But using Turbogears as Framework
avoids a lot of problems and the time can better be used to
do better code.
My famous programming language is Python of course and now
i am running into little problems using validators.
(actually solved with workarounds like type-conversion, ...)
I only want to know if it is really not possible to it
the way I would like it do do ;-)


I am having a method in one of my model that returns a list
containing tuples
e.g.
mylist = [(0, 'user0'), (1, 'user1'), ... ]

I use this list to feed it to a
widgets.SingleSelectField(name='user',
                        label='Users',
                        options=mylist
                        default=0)

As you can see I am passing the User ID as int()-object to the widget.

Rendering/displaying the list works like a charme.

The validation process of the form (the user part) should be done with
SchemaValidation
e.g.

Question #1:
(does not work because the validator wants int(), the form sends e.g.
u'0'
user = validators.OneOf( map(lambda user: user[0], myModel.getIDTuples
()) )
(myModel.getIDTuples results int the above example of "mylist")

It would be possible to use str(user[0]) in lambda-expression, but I
want to avoid
type conversion if NOT REALLY needed.

I also tried to chain validators with ForEach(Int(), OneOf( map(lambda
user: user[0], myModel.getIDTuples()) ))
This did not work because the validator resulted in [0] (a list-
object)

Is is really not possible to validate if the value is a valid int()
and then if it is in a given list?

#Question #2
SchemaValidation:

startdate, enddate are created with a widgets.CalendarDatePicker()

startdate       = validators.DateTimeConverter(format='%d.%m.%Y')
enddate         = validators.DateTimeConverter(format='%d.%m.%Y')

The validation in the given form works.
But how is possible to validate if the fields are of the correct form
(like above)
AND if startdate < enddate?

Best regards.
Werner


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to