Parameters for Zope External Method
Nick Belshaw
nickb at earth.ox.ac.uk
Fri Jan 28 10:48:51 EST 2000
Jyrki Alakuijala wrote:
> I have succeeded in creating a Zope external method which
> causes a python statement to be evaluated for a web request.
> However, I have failed to pass parameters (other than the
> special case "self") to that external method.
>
Well you must be most of the way there!!
>
> So, where can I find instructions on how to call an external
> method with parameters? I could not find that in the
> manuals.
>
Hmmm - the manuals are a bit 'distributed' aren't they. You may find
more useful info in the HOW-TOs
>
> Should I use something else than an external method?
>
Depends what you want! You can pass parameters to External Methods and
also call Zope stuff FROM external methods (with parameter passing) so -
how?
-------------------------------
little Python method in file testext.py
def little_method(self, something):
# any usfull stuff here which may use 'something'
return 'ok - I did something'
-------------------------------
Inside our Zope DTML-METHOD
....
just to show our passed parameter does exist in our namespace before we
use it
<dtml-var a_parameter>
<br>
<dtml-var "our_little_external_method(a_parameter)">
<br>
well did that work for you?
....
-------------------------------
and of course we had to create our External Method inside Zope (same
Folder?)
ID = 'our_little_external_method'
Title = 'Just testing'
Function name = 'little_method'
module = 'testext.py'
-------------------------------
That should do it - at least to first-order. My understanding is
superficial !!!
Inside our External Python Method we can also call any Zope Method via
the 'self' namespace....
def little_method(self, some_parameter):
# something useful here
self.zope_method_in_our_folder(some_parameter=some_value)
return 'whatever you like'
which will call the named zope_method_in_our_folder and make any named
passed parameters available as <dtml-var>s inside the folder.
Its all rather cryptic but neat at the same time. Worth a bit of effort
to understand me thinks.
-but-don't-ask-me-about-aquisition-ly yours
Nick
--
Dr Nick Belshaw Dept of Earth Sciences
Tel : 01865 272000 Oxford University
Fax : 01865 272072 Parks Rd, Oxford, OX2 3PR
More information about the Python-list
mailing list