SingleSelectField options Query.filter user_id

34 views
Skip to first unread message

RyanWilson

unread,
Nov 2, 2012, 10:39:13 AM11/2/12
to turbo...@googlegroups.com
Hi,

I'm populating the options of a SingleSelectField with a database query; however, I need to filter the query based on which user is logged in.  In my controllers I simply call request.identity['repoze.who.userid'] to find the user with which I filter the data.  When I try to make a call to request.identity from my a form, I get the following error: AttributeError: identity

How can I find out which user is logged in from a form?  If that's not possible in that context, how do I pass a variable from my controller to the form holding the user id?

Thanks!

Ryan

Moritz Schlarb

unread,
Nov 2, 2012, 5:01:10 PM11/2/12
to turbo...@googlegroups.com
I can just give you a vague answer, but there are methods on the widget, which get called within the .display() call in your template.
If you supply values to the call to .display(), you can access those in that functions and use it to display dynamic dropdown options.

Here's an example:

self.value holds exactly what you pass in to the call to .display().

RyanWilson

unread,
Nov 3, 2012, 1:01:32 AM11/3/12
to turbo...@googlegroups.com
Thank you!

I didn't know how to access what I pass into .display()

self.value should give me what I'm looking for.

Best,

Ryan

RyanWilson

unread,
Nov 5, 2012, 10:05:30 AM11/5/12
to turbo...@googlegroups.com
Working sweet.  Thanks!
Reply all
Reply to author
Forward
0 new messages