Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.script.xmlrpc.write.PluginScript Class Reference
Inheritance diagram for MoinMoin.script.xmlrpc.write.PluginScript:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.script.xmlrpc.write.PluginScript:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def mainloop
def init_request
def run
def logRuntime

Public Attributes

 argv
 request
 def_values
 parser
 args

Detailed Description

\
Purpose:
========
This tool allows you to edit a page with xmlrpc. It is more of a commented
example than an actual script.

Detailed Instructions:
======================
General syntax: moin xmlrpc write <targeturl> <username> <password> <pagename>

Example:
To edit the page 'FrontPage' on 'http://wiki.example.org/' using the username
'JohnSmith' and the password 'MyPass', changing the page contents
to 'This will be the new contents of the page!' use:
moin xmlrpc write http://wiki.example.org/ JohnSmith MyPass FrontPage
This will be the new contents of the page!
^D

Note: we automatically append ?action=xmlrpc2 to the target url given.

Definition at line 15 of file write.py.


Constructor & Destructor Documentation

def MoinMoin.script.xmlrpc.write.PluginScript.__init__ (   self,
  argv,
  def_values 
)

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 38 of file write.py.

00038 
00039     def __init__(self, argv, def_values):
00040         MoinScript.__init__(self, argv, def_values)
00041         self.argv = argv


Member Function Documentation

def MoinMoin.script.MoinScript.init_request (   self) [inherited]
create request 

Definition at line 174 of file __init__.py.

00174 
00175     def init_request(self):
00176         """ create request """
00177         from MoinMoin.web.contexts import ScriptContext
00178         url = self.options.wiki_url or None
00179         self.request = ScriptContext(url, self.options.page)

Here is the caller graph for this function:

def MoinMoin.script.Script.logRuntime (   self) [inherited]
Print the total command run time. 

Definition at line 148 of file __init__.py.

00148 
00149     def logRuntime(self):
00150         """ Print the total command run time. """
00151         if self.options.show_timing:
00152             log("Needed %.3f secs." % (time.clock() - _start_time, ))
00153 

Here is the call graph for this function:

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 43 of file write.py.

00043 
00044     def mainloop(self):
00045         # grab parameters
00046         url = self.argv[0] + '?action=xmlrpc2'
00047         user = self.argv[1]
00048         passwd = self.argv[2]
00049         pagename = self.argv[3]
00050 
00051         # get auth token from server giving username/password
00052         s = xmlrpclib.ServerProxy(url)
00053         token = s.getAuthToken(user, passwd)
00054 
00055         if not token:
00056             print 'Invalid username/password'
00057             return
00058 
00059         # Verify that the token is valid by using it
00060         # and checking that the result is 'SUCCESS'.
00061         # The token should be valid for 15 minutes.
00062         assert s.applyAuthToken(token) == 'SUCCESS'
00063 
00064         try:
00065             # read new page contents
00066             content = sys.stdin.read()
00067 
00068             # build a multicall object that
00069             mcall = xmlrpclib.MultiCall(s)
00070             # first applies the token and
00071             mcall.applyAuthToken(token)
00072             # then edits the page
00073             mcall.putPage(pagename, content)
00074 
00075             # now execute the multicall
00076             results = mcall()
00077 
00078             # everything should have worked
00079             # instead of the asserts you can have anything else
00080             # but you should definitely access all the results
00081             # once so that faults are checked and raised
00082             assert results[0] == 'SUCCESS'
00083             assert results[1] is True
00084 
00085         finally:
00086             # be nice to the server and clean up the token
00087             # regardless of what happened
00088             assert s.deleteAuthToken(token) == 'SUCCESS'
00089 
def MoinMoin.script.Script.run (   self,
  showtime = 1 
) [inherited]
Run the main function of a command. 

Definition at line 130 of file __init__.py.

00130 
00131     def run(self, showtime=1):
00132         """ Run the main function of a command. """
00133         global flag_quiet
00134         try:
00135             try:
00136                 self.options, self.args = self.parser.parse_args(self.argv)
00137                 flag_quiet = self.options.quiet
00138                 # ToDo check if we need to initialize request (self.init_request())
00139                 self.mainloop()
00140             except KeyboardInterrupt:
00141                 log("*** Interrupted by user!")
00142             except SystemExit:
00143                 showtime = 0
00144                 raise
00145         finally:
00146             if showtime:
00147                 self.logRuntime()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 135 of file __init__.py.

Reimplemented from MoinMoin.script.Script.

Definition at line 40 of file write.py.

Definition at line 102 of file __init__.py.

Definition at line 113 of file __init__.py.

Definition at line 178 of file __init__.py.


The documentation for this class was generated from the following file: