Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a4c2b748
Commit
a4c2b748
authored
Apr 25, 2003
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Patch #628208] Add optional support for the 'nil' extension
parent
abea7ea9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
Lib/xmlrpclib.py
Lib/xmlrpclib.py
+24
-8
No files found.
Lib/xmlrpclib.py
View file @
a4c2b748
...
...
@@ -566,11 +566,12 @@ class Marshaller:
# by the way, if you don't understand what's going on in here,
# that's perfectly ok.
def
__init__
(
self
,
encoding
=
None
):
def
__init__
(
self
,
encoding
=
None
,
allow_none
=
0
):
self
.
memo
=
{}
self
.
data
=
None
self
.
encoding
=
encoding
self
.
allow_none
=
allow_none
dispatch
=
{}
def
dumps
(
self
,
values
):
...
...
@@ -606,6 +607,12 @@ class Marshaller:
else
:
f
(
self
,
value
,
write
)
def
dump_nil
(
self
,
value
,
write
):
if
not
self
.
allow_none
:
raise
TypeError
,
"cannot marshal None unless allow_none is enabled"
write
(
"<value><nil/></value>"
)
dispatch
[
NoneType
]
=
dump_nil
def
dump_int
(
self
,
value
,
write
):
# in case ints are > 32 bits
if
value
>
MAXINT
or
value
<
MININT
:
...
...
@@ -773,6 +780,11 @@ class Unmarshaller:
dispatch
=
{}
def
end_nil
(
self
,
data
):
self
.
append
(
None
)
self
.
_value
=
0
dispatch
[
"nil"
]
=
end_nil
def
end_boolean
(
self
,
data
):
if
data
==
"0"
:
self
.
append
(
False
)
...
...
@@ -899,7 +911,8 @@ def getparser():
# @keyparam encoding The packet encoding.
# @return A string containing marshalled data.
def
dumps
(
params
,
methodname
=
None
,
methodresponse
=
None
,
encoding
=
None
):
def
dumps
(
params
,
methodname
=
None
,
methodresponse
=
None
,
encoding
=
None
,
allow_none
=
0
):
"""data [,options] -> marshalled data
Convert an argument tuple or a Fault instance to an XML-RPC
...
...
@@ -935,7 +948,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None):
if
FastMarshaller
:
m
=
FastMarshaller
(
encoding
)
else
:
m
=
Marshaller
(
encoding
)
m
=
Marshaller
(
encoding
,
allow_none
)
data
=
m
.
dumps
(
params
)
...
...
@@ -1258,7 +1271,8 @@ class ServerProxy:
the given encoding.
"""
def
__init__
(
self
,
uri
,
transport
=
None
,
encoding
=
None
,
verbose
=
0
):
def
__init__
(
self
,
uri
,
transport
=
None
,
encoding
=
None
,
verbose
=
0
,
allow_none
=
0
):
# establish a "logical" server connection
# get the url
...
...
@@ -1279,11 +1293,13 @@ class ServerProxy:
self
.
__encoding
=
encoding
self
.
__verbose
=
verbose
self
.
__allow_none
=
allow_none
def
__request
(
self
,
methodname
,
params
):
# call a method on the remote server
request
=
dumps
(
params
,
methodname
,
encoding
=
self
.
__encoding
)
request
=
dumps
(
params
,
methodname
,
encoding
=
self
.
__encoding
,
allow_none
=
self
.
__allow_none
)
response
=
self
.
__transport
.
request
(
self
.
__host
,
...
...
@@ -1324,7 +1340,7 @@ if __name__ == "__main__":
# simple test program (from the XML-RPC specification)
# server = ServerProxy("http://localhost:8000") # local server
server
=
ServerProxy
(
"http://betty.userland.com"
)
server
=
ServerProxy
(
"http://betty.userland.com"
)
print
server
...
...
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