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
63f78ddc
Commit
63f78ddc
authored
Mar 18, 1999
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added hooks for XML-RPC
parent
74a3d213
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
8 deletions
+79
-8
lib/python/ZPublisher/HTTPRequest.py
lib/python/ZPublisher/HTTPRequest.py
+19
-5
lib/python/ZPublisher/Publish.py
lib/python/ZPublisher/Publish.py
+3
-3
lib/python/ZPublisher/xmlrpc.py
lib/python/ZPublisher/xmlrpc.py
+57
-0
No files found.
lib/python/ZPublisher/HTTPRequest.py
View file @
63f78ddc
...
...
@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
import
regex
,
sys
,
os
from
string
import
lower
,
atoi
,
rfind
,
split
,
strip
,
join
,
upper
,
find
...
...
@@ -92,7 +92,7 @@ from cgi import FieldStorage
from
urllib
import
quote
,
unquote
from
Converters
import
type_converters
from
maybe_lock
import
allocate_lock
xmlrpc
=
None
# Placeholder for module that we'll import if we have to.
isCGI_NAME
=
{
'SERVER_SOFTWARE'
:
1
,
...
...
@@ -167,16 +167,20 @@ class HTTPRequest(BaseRequest):
other variables, form data, and then cookies.
"""
_hacked_path
=
None
args
=
()
def
__init__
(
self
,
stdin
,
environ
,
response
,
clean
=
0
):
# Avoid the overhead of scrubbing the environment in the
# case of request cloning for traversal purposes. If the
# clean flag is set, we know we can use the passed in
# environ dict directly.
if
not
clean
:
environ
=
sane_environment
(
environ
)
method
=
environ
.
get
(
'REQUEST_METHOD'
,
'GET'
)
if
environ
.
get
(
'REQUEST_METHOD'
,
'GET'
)
!=
'GET'
:
fp
=
stdin
else
:
fp
=
None
if
method
!=
'GET'
:
fp
=
stdin
else
:
fp
=
None
if
environ
.
has_key
(
'HTTP_AUTHORIZATION'
):
self
.
_auth
=
environ
[
'HTTP_AUTHORIZATION'
]
...
...
@@ -188,7 +192,17 @@ class HTTPRequest(BaseRequest):
meth
=
None
fs
=
FieldStorage
(
fp
=
fp
,
environ
=
environ
,
keep_blank_values
=
1
)
if
not
hasattr
(
fs
,
'list'
)
or
fs
.
list
is
None
:
form
[
'BODY'
]
=
fs
.
value
# Hm, maybe it's an XML-RPC
if
(
fs
.
headers
.
has_key
(
'content-type'
)
and
fs
.
headers
[
'content-type'
]
==
'text/xml'
and
method
==
'POST'
):
# Ye haaa, XML-RPC!
global
xmlrpc
if
xmlrpc
is
None
:
import
xmlrpc
meth
,
self
.
args
=
xmlrpc
.
parse_input
(
fs
.
value
)
response
=
xmlrpc
.
response
(
response
)
else
:
form
[
'BODY'
]
=
fs
.
value
else
:
fslist
=
fs
.
list
tuple_items
=
{}
...
...
lib/python/ZPublisher/Publish.py
View file @
63f78ddc
...
...
@@ -84,8 +84,8 @@
##############################################################################
__doc__
=
"""Python Object Publisher -- Publish Python objects on web servers
$Id: Publish.py,v 1.12
6 1999/03/10 00:15:51 kl
m Exp $"""
__version__
=
'$Revision: 1.12
6
$'
[
11
:
-
2
]
$Id: Publish.py,v 1.12
7 1999/03/18 22:36:23 ji
m Exp $"""
__version__
=
'$Revision: 1.12
7
$'
[
11
:
-
2
]
import
sys
,
os
from
string
import
lower
,
atoi
,
rfind
,
strip
...
...
@@ -154,7 +154,7 @@ def publish(request, module_name, after_list, debug=0,
(
request_get
(
'AUTHENTICATION_PATH'
),
auth_user
))
+
info
transaction
.
note
(
info
)
result
=
mapply
(
object
,
(),
request
,
result
=
mapply
(
object
,
request
.
args
,
request
,
call_object
,
1
,
missing_name
,
dont_publish_class
,
...
...
lib/python/ZPublisher/xmlrpc.py
0 → 100644
View file @
63f78ddc
"""Skeleton XML-RPC support module
"""
import
HTTPResponse
def
parse_input
(
data
):
"""Parse input data and return a method path and argument tuple
The data is a string (but maybe it should be a file, oh well,
we'll come back to this if necessary.
"""
#
# For example, with the input:
#
# <?xml version="1.0"?>
# <methodCall>
# <methodName>examples.getStateName</methodName>
# <params>
# <param>
# <value><i4>41</i4></value>
# </param>
# </params>
# </methodCall>
#
# the function should return:
#
# ('examples.getStateName', (41,))
return
''
,
()
def
response
(
anHTTPResponse
):
"""Return a valid ZPublisher response object
Use data already gathered by the existing response.
The new response will replace the existing response.
"""
# As a first cut, lets just clone the response and
# put all of the logic in our refined response class below.
r
=
Response
()
r
.
__dict__
.
update
(
anHTTPResponse
.
__dict__
)
return
r
########################################################################
# Possible implementation helpers:
class
Response
(
HTTPResponse
.
HTTPResponse
):
"""Customized HTTPResponse that handles XML-RPC-specific details
I'm just guessing here. XML-RPC wants all errors to be converted
to XML and returned with an 200 OK status.
You'll probably need to override a bunch of the error
handling logic.
"""
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