Personal tools
You are here: Home Documentation How To's Python code to log into a remote Plone site

Python code to log into a remote Plone site

by Nguyen, T. Kim last modified Sep 16, 2013 10:28 AM

This seems to work:

I invoke Python, log in with either a Zope admin account or a NetID account, and invoke a method that normally requires being logged in:

$ cd /Users/kim/Plone-4.3/zinstance
$ ../Python-2.7/bin/python

>>> import xmlrpclib
>>> xmlrpclib.ServerProxy(target).listFolderContents()
 
<?xml version='1.0'?>\n<methodResponse>\n<params>\n<param>\n<value><array><data>\n<value><struct>\n<member>\n<name>defaultSeverity</name>\n<value><string>Medium</string></value>\n</member>\n<member>\n<name>availableIssueTypes</name>\n<value><array><data>\n<value><struct>\n<member>\n<name>id</name>\n<value><string>bug</string></value>\n</member>\n<member>\n<name>description</name>\n<value><string>Func
...
 
This will spit out the contents (in XML format) of my home folder, but if I tried this instead without logging in
 
>>> import xmlrpclib
>>> xmlrpclib.ServerProxy(target).listFolderContents()
 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1575, in __request
    verbose=self.__verbose
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1312, in single_request
    response.msg,
xmlrpclib.ProtocolError: <ProtocolError for plone3.webcluster.uwosh.edu:15082/Intranet/Members/nguyen/: 401 Unauthorized>
 
This works with a direct connection to the ZEO client or instance, not necessarily through a public URL that goes through squid, pound, and Apache.
 
Document Actions
  • Print this
  • Bookmarks