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
1d45d7a1
Commit
1d45d7a1
authored
Jan 21, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new interface and now can use bound methods
parent
8a2d343a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
37 deletions
+29
-37
lib/python/Products/ExternalMethod/ExternalMethod.py
lib/python/Products/ExternalMethod/ExternalMethod.py
+19
-25
lib/python/Products/ExternalMethod/methodAdd.dtml
lib/python/Products/ExternalMethod/methodAdd.dtml
+4
-6
lib/python/Products/ExternalMethod/methodEdit.dtml
lib/python/Products/ExternalMethod/methodEdit.dtml
+6
-6
lib/python/Products/ExternalMethod/www/function.gif
lib/python/Products/ExternalMethod/www/function.gif
+0
-0
No files found.
lib/python/Products/ExternalMethod/ExternalMethod.py
View file @
1d45d7a1
...
@@ -16,10 +16,8 @@ modules={}
...
@@ -16,10 +16,8 @@ modules={}
addForm
=
HTMLFile
(
'methodAdd'
,
globals
())
addForm
=
HTMLFile
(
'methodAdd'
,
globals
())
def
add
(
self
,
id
,
title
,
external_name
,
REQUEST
=
None
):
def
add
(
self
,
id
,
title
,
module
,
function
,
REQUEST
=
None
):
"""Add an external method to a folder"""
"""Add an external method to a folder"""
names
=
split
(
external_name
,
'.'
)
module
,
function
=
join
(
names
[:
-
1
],
'.'
),
names
[
-
1
]
i
=
ExternalMethod
(
id
,
title
,
module
,
function
)
i
=
ExternalMethod
(
id
,
title
,
module
,
function
)
self
.
_setObject
(
id
,
i
)
self
.
_setObject
(
id
,
i
)
return
self
.
manage_main
(
self
,
REQUEST
)
return
self
.
manage_main
(
self
,
REQUEST
)
...
@@ -40,22 +38,16 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent,
...
@@ -40,22 +38,16 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent,
{
'label'
:
'Access Control'
,
'action'
:
'manage_access'
},
{
'label'
:
'Access Control'
,
'action'
:
'manage_access'
},
)
)
def
__init__
(
self
,
id
=
''
,
title
=
''
,
module
=
''
,
function
=
''
):
def
__init__
(
self
,
id
,
title
,
module
,
function
):
if
id
:
self
.
id
=
id
self
.
id
=
id
self
.
title
=
title
self
.
manage_edit
(
title
,
module
,
function
)
self
.
_module
=
module
self
.
_function
=
function
self
.
getFunction
()
self
.
_p_atime
=
1
manage_main
=
HTMLFile
(
'methodEdit'
,
globals
())
manage_main
=
HTMLFile
(
'methodEdit'
,
globals
())
def
manage_edit
(
self
,
title
,
REQUEST
=
None
):
def
manage_edit
(
self
,
title
,
module
,
function
,
REQUEST
=
None
):
"Change the external method"
"Change the external method"
self
.
title
=
title
self
.
title
=
title
names
=
split
(
external_name
,
'.'
)
if
module
[
-
3
:]
==
'.py'
:
module
=
module
[:
-
3
]
module
,
function
=
join
(
names
[:
-
1
],
'.'
),
names
[
-
1
]
elif
module
[
-
4
:]
==
'.py'
:
module
=
module
[:
-
4
]
self
.
_module
=
module
self
.
_module
=
module
self
.
_function
=
function
self
.
_function
=
function
try
:
del
modules
[
module
]
try
:
del
modules
[
module
]
...
@@ -64,11 +56,9 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent,
...
@@ -64,11 +56,9 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent,
if
REQUEST
:
return
MessageDialog
(
if
REQUEST
:
return
MessageDialog
(
title
=
'Changed %s'
%
self
.
id
,
title
=
'Changed %s'
%
self
.
id
,
message
=
'%s has been updated'
%
self
.
id
,
message
=
'%s has been updated'
%
self
.
id
,
action
=
REQUEST
[
'URL
2
'
]
+
'/manage_main'
,
action
=
REQUEST
[
'URL
1
'
]
+
'/manage_main'
,
target
=
'manage_main'
)
target
=
'manage_main'
)
def
external_name
(
self
):
return
"%s.%s"
%
(
self
.
_module
,
self
.
_function
)
def
getFunction
(
self
):
def
getFunction
(
self
):
module
=
self
.
_module
module
=
self
.
_module
...
@@ -83,10 +73,13 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent,
...
@@ -83,10 +73,13 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent,
modules
[
module
]
=
m
modules
[
module
]
=
m
f
=
m
[
self
.
_function
]
f
=
m
[
self
.
_function
]
if
self
.
func_defaults
!=
f
.
func_defaults
:
if
hasattr
(
f
,
'im_func'
):
ff
=
f
.
im_func
self
.
func_defaults
=
f
.
func_defaults
else
:
ff
=
f
if
self
.
func_defaults
!=
ff
.
func_defaults
:
self
.
func_defaults
=
ff
.
func_defaults
func_code
=
FuncCode
(
f
)
func_code
=
FuncCode
(
f
f
,
f
is
not
ff
)
if
func_code
!=
self
.
func_code
:
self
.
func_code
=
func_code
if
func_code
!=
self
.
func_code
:
self
.
func_code
=
func_code
self
.
_v_f
=
f
self
.
_v_f
=
f
...
@@ -99,13 +92,14 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent,
...
@@ -99,13 +92,14 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent,
return
apply
(
f
,
args
)
return
apply
(
f
,
args
)
def
function
(
self
):
return
self
.
_function
def
module
(
self
):
return
self
.
_module
class
FuncCode
:
class
FuncCode
:
def
__init__
(
self
,
f
=
None
):
def
__init__
(
self
,
f
,
im
=
0
):
if
f
is
not
None
:
self
.
co_varnames
=
f
.
func_code
.
co_varnames
[
im
:]
self
.
co_varnames
=
f
.
func_code
.
co_varnames
self
.
co_argcount
=
f
.
func_code
.
co_argcount
-
im
self
.
co_argcount
=
f
.
func_code
.
co_argcount
def
__cmp__
(
self
,
other
):
def
__cmp__
(
self
,
other
):
return
cmp
((
self
.
co_argcount
,
self
.
co_varnames
),
return
cmp
((
self
.
co_argcount
,
self
.
co_varnames
),
...
...
lib/python/Products/ExternalMethod/methodAdd.dtml
View file @
1d45d7a1
...
@@ -16,12 +16,10 @@
...
@@ -16,12 +16,10 @@
<TD ALIGN="LEFT" VALIGN="TOP"><B>Title</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><B>Title</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD>
</TR>
</TR>
<TR>
<tr> <th>Function name</th>
<TD ALIGN="LEFT" VALIGN="TOP"><B>External name</B></TD>
<td><input name="function" size="30"></td></tr>
<TD ALIGN="LEFT" VALIGN="TOP">
<tr> <th>Python module file</th>
<INPUT TYPE="TEXT" NAME="external_name" SIZE="50">
<td><input name="module" size="30"></td></tr>
</TD>
</TR>
<TR>
<TR>
<TD></TD>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add"></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add"></TD>
...
...
lib/python/Products/ExternalMethod/methodEdit.dtml
View file @
1d45d7a1
...
@@ -19,13 +19,13 @@
...
@@ -19,13 +19,13 @@
<INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="<!--#var title-->">
<INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="<!--#var title-->">
</TD>
</TD>
</TR>
</TR>
<tr> <th>Function name</th>
<td><input name="function" size="30"
value="<!--#var function-->"></td></tr>
<tr> <th>Python module file (without suffix)</th>
<td><input name="module" size="30"
value="<!--#var module-->"></td></tr>
<TR>
<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>
<TR>
<TD></TD>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Edit"></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Edit"></TD>
...
...
lib/python/Products/ExternalMethod/www/function.gif
View replaced file @
8a2d343a
View file @
1d45d7a1
871 Bytes
|
W:
|
H:
895 Bytes
|
W:
|
H:
2-up
Swipe
Onion skin
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