Hi all,
I have a question. My setup is below (well, a simplified version). I
want to create a form in a controller that incorporates forms created
by methods in other controllers. To do this in AController I call
cherrypy.root.bcontroller.listData() to access the listData method of
the bcontroller (which is instantiated in the RootController). When I
do this I get an empty DataGrid form. (just the start tags for the
table are there but no contents). When I directly access the /
bcontroller/list url on the server, the DataGrid is rendered
correctly. I guess this has something todo with templating and
exposing the method. If I on the other hand call bcontroller.list
method from AController, I don't get a dictionary returned by
bcontroller.list, but a string with the rendered html of the form. I
guess this is again of the @expose(template=...) part. The method,
when called, directly renders the form somehow. But I don't want that,
I want to get the dictionary with the form and value separately. How
can I solve this?
Cheers,
Dolf.
import cherrypy
RootController(RootController)
...
acontroller=AController()
bcontroller=BController()
a_form=TableForm(fields=alistoffields)
b_form=DataGrid(fields=blistoffields)
ACrontroller(Controller):
@expose(template="templates.atemplate")
def show(self,id)
a=model.AClass.get(id=id)
b=cherrypy.root.bcontroller.listData(ids=[b.id for b in
a.blist])
title="sometitle"
return dict(forms:
[{'form':a_form,'value':a},bresult],'title'=title)
BController(Controller)
@expose(template="templates.btemplate")
def list(self,ids):
return self.listData(ids)
def listData(self,ids):
bs=[model.BClass.get(id) for id in ids]
return dict(form:b_form,value:bs)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---