Commit 6651320c authored by Jim Fulton's avatar Jim Fulton

first cut, no testing

parent d53be4db
"""External Method Product
This product provides support for external methods, which allow
domain-specific customization of web environments.
"""
from Acquisition import Implicit
brain_dir=SOFTWARE_HOME+'/Extensions'
modules={}
def add(self, id, title, roles, external_name, REQUEST=None):
"""Add an external method to a folder"""
names=split(external_name,'.')
module, function = join(names[:-1],'.'), names[-1]
i=ExternalMethod(id,title,roles,module,function)
self._setObject(name,i)
return self.manage_main(self,REQUEST)
class ExternalMethod:
"""An external method is a web-callable function that encapsulates
an external function."""
meta_type='External Method'
def __init__(self, id='', title='', roles='', module='', function=''):
if id:
self.id=id
self.title=title
self.roles=roles
self._module=module
self._function=function
self.getFunction()
self._p_atime=1
def getFunction(self):
module=self._module
try: m=modules[module]
except:
m={}
exec open("%s/%s.py" % (braindir, module)) in m
modules[module]=m
f=m[self._function]
if self.func_defaults != f.func_defaults:
self.func_defaults = f.func_defaults
func_code=FuncCode(f)
if func_code != self.func_code: self.func_code=func_code
self._v_f=f
return f
def __call__(self, *args):
try: f=self._v_f
except: f=self.getFunction()
return apply(f,args)
class FuncCode:
def __init__(self, f):
self.co_varnames=f.func_code.co_varnames
self.co_argcount=f.func_code.co_argcount
def __cmp__(self,other):
return cmp((self.co_argcount, self.co_varnames),
(othr.co_argcount, othr.co_varnames))
##############################################################################
#
# Copyright
#
# Copyright 1997 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
##############################################################################
__doc__='''External Method Product Initialization
$Id: __init__.py,v 1.1 1997/10/09 17:34:53 jim Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
import ExternalMethod
__.meta_types= {'name':'External Method',
'action':'manage_addExternalMethodForm'
},
__.methods={
'manage_addExternalMethodForm': ExternalMethod.addForm,
'manage_addExternalMethod': ExternalMethod.add,
}
##############################################################################
#
# $Log: __init__.py,v $
# Revision 1.1 1997/10/09 17:34:53 jim
# first cut, no testing
#
# Revision 1.1 1997/07/25 18:14:28 jim
# initial
#
#
<HTML>
<HEAD>
<TITLE>New External Method</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2" COLOR="#77003B">New External Method</FONT>
<FORM ACTION="manage_addExternalMethod" METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>Id</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="id" SIZE="50"></TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>Title</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>External name:</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="ExternalName" SIZE="50">
</TD>
</TR>
<TR>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add External Method"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment