Chris wrote:
> Hello all,
>
> I'm starting from the wiki article on dynamically building the option
> lists in a multiple select field.
> http://trac.turbogears.org/turbogears/wiki/PassingArgumentsToCallables
>
> However, what I'm doing now involves 2 modifications:
> 1.  I want the string part of the select field to be the synthesis of 2
> DB fields.  What I did here was to create a custom build_list()
> function on my SQLObject.  OK.
>
> 2.  I want to be able to dynamically change the filter on the return
> list.  From the wiki page, what I want to be able to do is something
> like:
> # Only list colors that have some red in them, and sort alphabetically.
> widget = SingleSelectField('colors', options=make_list(Color, None,
> 'name',
>         Color.q.r > someVarible, orderBy=Color.q.name)
> where I have changed "Color.q.r > 0" to "Color.q.r > someVariable".
>
> I'm hoping to keep this all in my code, but I'm having a hard time
> finding a thread safe solution.  I'm leaning towards creating a JSON
> call and dynamically building the list on the client side.  Any other
> ideas?
>
> Chris

Hi Chris,

I have often found it useful to put things in charrypy.request.  You
could, for example, in your controller method do:

    cherrypy.request.min_r = someVariable

and then in make_list() (with no parameters), do:

    Color.select(Color.q.r > cherrypy.request.min_r)

The reson that this works is because cherrypy.request is data for one
request and is thread safe.  The execution order is your controller,
then expose which calls kid which calls your widget which calls
make_list.  So the variables you put in cherrypy.request are stored
first and then used.  They are also automatically thrown away from
request to request.

Anyway, HTH, and I hope I explained it clearly enough.  Basically stuff
things in cherrypy.request for later retrieval.

Krys


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to