[Zope] calling a DTML Method from a DTML MEthod from a PythonPRoduct...

Alexis Roda alexis.roda at urv.es
Wed Sep 8 05:52:46 EDT 2004


Bill Hewitt wrote:
> Ive got a need to call a DTML Method from a DTML Method I call in a
> Python Product:
> 
> In the Python File, I use to call the Creation Form (a DTML Method):
> 
> manage_addCampusForm = HTMLFile('campus_dtml/CampusAddForm',globals())

This is a module level variable, not a class attribute, right?

> manage_addCampusForm needs to call:
> 
> tableSubmitButtons =
> HTMLFile('campus_dtml/tableSubmitButtons',globals())
> 
> Which is in the same directory as "manage_addCampusForm".

That don't matter.

> Where do I put
> the second method above so that the Python Product/first DTML method
> finds it? so far I have tried to just add it to the bottom of the file
> and in the Class Definition - but I get an error that the
> "tableSubmitButtons" method cant be found....

If I understand what you're trying you have at least two choices:

*first*
pass explicitly the rendered tableSubmitButtons to manage_addCampusForm:


_manage_addCampusForm = DTMLFile(...)
_tableSubmitButtons = DTMLFile(...)
def manage_addCampusForm(...) :
   return _manage_addCampusForm(...,
                                buttons=_tableSubmitButtons(...))

and in the CampusForm DTML:

<dtml-var buttons>


*second*
add an extra constructor, so manage_addCampusForm can locate 
tableSubmitButtons:

from YourModule import manage_addCampusForm
from YourModule import manage_addCampus
from YourModule import tableSubmitButtons

context.registerClass(...,
                       constructors=(manage_addCampusForm,
                                     manage_addForm,
                                     tableSubmitButtons),
                       ...)


Just curious, why you separate the form from the submit buttons?



HTH
-- 
                                    ////
                                   (@ @)
----------------------------oOO----(_)----OOo--------------------------
<>               Ojo por ojo y el mundo acabara ciego
/\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
-----------------------------------------------------------------------



More information about the Zope mailing list