calling a DTML Method from a DTML MEthod from a Python PRoduct...
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()) manage_addCampusForm needs to call: tableSubmitButtons = HTMLFile('campus_dtml/tableSubmitButtons',globals()) Which is in the same directory as "manage_addCampusForm". 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.... What am I doing wrong here? TIA WPH
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):
Note. DTMLFile (HTMLFile have changed name) is not identical to DTML Method.
manage_addCampusForm = HTMLFile('campus_dtml/CampusAddForm',globals())
manage_addCampusForm needs to call:
tableSubmitButtons = HTMLFile('campus_dtml/tableSubmitButtons',globals())
Which is in the same directory as "manage_addCampusForm". Where do I put the second method above so that the Python Product/first DTML method finds it?
If both are defined in the same class they are accessed from the instance object (self) which is create long after the class definition is executed. There for the order in which they are defined doesn't matter :-) The problem is, if I understand you correctly that you want to add a second "constructor" method to be used during Product Instantiation? The Product constructors are usually define at modular level and added to the Zope Product machinery during Product registation in the initialize(context) method for that product. context.registerClass( ... constructors=(<Module>.manage_addMethodForm, <Module>.manage_addMethod), ... ...) You should be able to add extra methods here. But, you must know where it will appear i Zope to be able to use it. Accessing the methods fomr easy other they are in the same context of it would work fine. Accessing it from outside the Product Add context you need to look them up in the correct product context, like this: manage_addProduct['<product name>'].<method name> Regards, Johan Carlsson -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: johanc@easypublisher.com SE-113 37 STOCKHOLM
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) -----------------------------------------------------------------------
participants (3)
-
Alexis Roda -
Bill Hewitt -
Johan Carlsson