To use an External Method, you need to place your Python source code file in the Extensions directory in of your Zope directory (you may need to create this directory), or in an Extensions directory inside a Product directory, e.g. lib/python/Products/MyProduct/Extensions .
|
Next, create an External Method with Zope's management interface. Choose "External Method" from the list of addable objects. Then specify your function name and the name of your source file (without suffix). Voila, your Python code runs in Zope without having to master writing a Zope Product from scratch! Stan creates the text.py file under the Extensions directory, just copy and paste from the example the function
|
External Methods need not actually be bound to the current Folder, but can operate as a function if you wish. Figure 57 provides two examples showing the difference between a function, KnowNothing and a method, FolderTitle .
return "I know nothing of Folders and such." # this is a method of a folder object |
When adding external methods, you will have to option of trying out your code before implementing the code. The "Try It" tag, allows you to experiment with your python program. Of course the powerful, "Undo" option can wipe away your mistakes with a single key stroke.
|