I have a form:
class X(widgets.WidgetsList):
blog = widgets.SingleSelectField(label="Blog", options=get_blogs)
with a function:
def get_blogs():
return [(blog.id, blog.title)
for blog in identity.current.identity().user.blogs]
and as seen in this (unresolved) thread:
http://groups.google.com/group/turbogears/browse_thread/thread/b1c764b56c1153eb/477c254accec0402?
it is impossible (or at least to the best of my knowledge) to access
identity when a form is created because, again, to the best of my
knowledge and from the errors TurboGears is giving me, that happens
outside of a request. Specifically:
turbogears.identity.exceptions.RequestRequiredException: An attempt was
made to use a facility of the TurboGears Identity Management framework
that relies on an HTTP request outside of a request.
What I need is a way to make it so I can dynamically add options to
X.blog from /within/ a request. I imagine I can do this by
manipulationg the TableForm object it's placed into, but even that is
created /outside/ of a request. So, still, I need to create options my
SingleSelectField on the fly from wthin the action. How, though? I have
gotten this far:
def action(self, tg_errors=None, *args, **kw):
my_form.fields.append(my_dymanically_generated_SingleSelectField)
But then, why even use the forms api? I have to roll my own validation
for that and other fields that are generated depending on the user
accessing the action. If someone could please look at my problem, I'd
be very greatful.
Thanks,
-Sam
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---