Skip to content. | Skip to navigation

Personal tools


You are here: Home / Tips / External Method

External Method

Zope 提供 External Method 機制,用來透過網頁執行 Python 程式,並能處理檔案系統層面的資料。

example: whois

add external method while installing product

in profiles/default create import_steps.xml

Import easysearch settings

in the product create file like this

# created by tareq alam
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_hasattr
from Products.Archetypes.public import listTypes


def importVarious(context):
Final easysearch import steps.


site = context.getSite()
invokeFactory = getToolByName(site, 'invokeFactory')
manage_delObjects = getToolByName(site, 'manage_delObjects')
#getattr = getToolByName(site, 'getattr')


Newfolder = invokeFactory("Folder", id="reportExternalMethods", title="reportExternalMethods",path='/')
Newfolderobj = getattr(site, Newfolder, None)
manage_addProduct = getToolByName(Newfolderobj, 'manage_addProduct')


em = manage_addProduct['ExternalMethod']
manage_addExternalMethod = getToolByName(em, 'manage_addExternalMethod')
manage_addExternalMethod('imageexample', 'imageexample', 'easysearch.imageexample', 'imageexample')
manage_addExternalMethod('createResultPy', 'createResultPy', 'easysearch.createResultPy', 'createResultPy')


#em = context.manage_addProduct['ExternalMethod']







now restart and install product, this will create a folder reportExternalMethods in root .. and also create two external methods in that folder

Prevent External Method Directory From Removed By Rerunning Buildout

TypeError: expected string or Unicode object, NoneType found