Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
8707f471
Commit
8707f471
authored
Oct 09, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first working version
parent
6651320c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
16 deletions
+85
-16
lib/python/Products/ExternalMethod/ExternalMethod.py
lib/python/Products/ExternalMethod/ExternalMethod.py
+39
-10
lib/python/Products/ExternalMethod/Setup
lib/python/Products/ExternalMethod/Setup
+6
-1
lib/python/Products/ExternalMethod/methodAdd.dtml
lib/python/Products/ExternalMethod/methodAdd.dtml
+5
-5
lib/python/Products/ExternalMethod/methodEdit.dtml
lib/python/Products/ExternalMethod/methodEdit.dtml
+35
-0
No files found.
lib/python/Products/ExternalMethod/ExternalMethod.py
View file @
8707f471
...
...
@@ -6,34 +6,62 @@ domain-specific customization of web environments.
"""
from
Acquisition
import
Implicit
from
Globals
import
Persistent
,
HTMLFile
,
MessageDialog
import
OFS.SimpleItem
from
string
import
split
,
join
import
AccessControl.Role
brain
_
dir
=
SOFTWARE_HOME
+
'/Extensions'
braindir
=
SOFTWARE_HOME
+
'/Extensions'
modules
=
{}
def
add
(
self
,
id
,
title
,
roles
,
external_name
,
REQUEST
=
None
):
addForm
=
HTMLFile
(
'ExternalMethod/methodAdd'
)
def
add
(
self
,
id
,
title
,
external_name
,
acl_type
=
'A'
,
acl_roles
=
[],
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
)
i
=
ExternalMethod
(
id
,
title
,
module
,
function
)
i
.
_setRoles
(
acl_type
,
acl_roles
)
self
.
_setObject
(
id
,
i
)
return
self
.
manage_main
(
self
,
REQUEST
)
class
ExternalMethod
:
class
ExternalMethod
(
OFS
.
SimpleItem
.
Item
,
Persistent
,
AccessControl
.
Role
.
RoleManager
)
:
"""An external method is a web-callable function that encapsulates
an external function."""
meta_type
=
'External Method'
icon
=
'ExternalMethod/function.gif'
func_defaults
=
()
func_code
=
None
def
__init__
(
self
,
id
=
''
,
title
=
''
,
roles
=
''
,
module
=
''
,
function
=
''
):
def
__init__
(
self
,
id
=
''
,
title
=
''
,
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
manage
=
HTMLFile
(
'ExternalMethod/methodEdit'
)
def
manage_edit
(
self
,
title
,
external_name
,
acl_type
=
'A'
,
acl_roles
=
[],
REQUEST
=
None
):
"Change the external method"
self
.
title
=
title
names
=
split
(
external_name
,
'.'
)
module
,
function
=
join
(
names
[:
-
1
],
'.'
),
names
[
-
1
]
self
.
_module
=
module
self
.
_function
=
function
self
.
getFunction
()
self
.
_setRoles
(
acl_type
,
acl_roles
)
if
REQUEST
:
return
MessageDialog
(
title
=
'Changed %s'
%
self
.
id
,
message
=
'%s has been updated'
%
self
.
id
,
action
=
REQUEST
[
'URL2'
]
+
'/manage_main'
,
target
=
'manage_main'
)
def
external_name
(
self
):
return
"%s.%s"
%
(
self
.
_module
,
self
.
_function
)
def
getFunction
(
self
):
module
=
self
.
_module
...
...
@@ -64,9 +92,10 @@ class ExternalMethod:
class
FuncCode
:
def
__init__
(
self
,
f
):
self
.
co_varnames
=
f
.
func_code
.
co_varnames
self
.
co_argcount
=
f
.
func_code
.
co_argcount
def
__init__
(
self
,
f
=
None
):
if
f
is
not
None
:
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
),
...
...
lib/python/Products/ExternalMethod/Setup
View file @
8707f471
*shared*
# install ExternalMethod.py
# install __init__.py
# install addForm.dtml
# install methodAdd.dtml
# install methodEdit.dtml
# install www www/%(package)s
lib/python/Products/ExternalMethod/
addForm
.dtml
→
lib/python/Products/ExternalMethod/
methodAdd
.dtml
View file @
8707f471
...
...
@@ -3,7 +3,7 @@
<TITLE>New External Method</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<
FONT SIZE="+2" COLOR="#77003B">New External Method</FONT
>
<
h2>New External Method</h2
>
<FORM ACTION="manage_addExternalMethod" METHOD="POST">
<TABLE CELLSPACING="2">
...
...
@@ -15,18 +15,18 @@
<TD ALIGN="LEFT" VALIGN="TOP"><B>Title</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD>
</TR>
<!--#var smallRolesWidget-->
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>External name
:
</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><B>External name</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="
ExternalN
ame" SIZE="50">
<INPUT TYPE="TEXT" NAME="
external_n
ame" SIZE="50">
</TD>
</TR>
<TR>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add
External Method
"></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
lib/python/Products/ExternalMethod/methodEdit.dtml
0 → 100644
View file @
8707f471
<HTML>
<HEAD>
<TITLE>Edit <!--#var title_or_id--></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<h2>Edit <!--#var title_or_id--></h2>
<FORM ACTION="manage_edit" METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>Id</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><!--#var id--></TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>Title</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="<!--#var title-->">
</TD>
</TR>
<!--#var smallRolesWidget-->
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>External name</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="external_name" SIZE="50"
VALUE="<!--#var external_name-->">
</TD>
</TR>
<TR>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Edit"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment