comparison MoinMoin/xmlrpc/__init__.py @ 5816:b661a89ef0be

xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 25 Dec 2011 23:56:09 +0100
parents a7b3ccda38d8
children dfbc455e2c46
comparison
equal deleted inserted replaced
5815:a7b3ccda38d8 5816:b661a89ef0be
444 'name': self._outstr(page.page_name), 444 'name': self._outstr(page.page_name),
445 'lastModified': xmlrpclib.DateTime(gmtuple), 445 'lastModified': xmlrpclib.DateTime(gmtuple),
446 'author': self._outstr(edit_info['editor']), 446 'author': self._outstr(edit_info['editor']),
447 'version': version, 447 'version': version,
448 } 448 }
449
450 def xmlrpc_getProcessingInstruction(self, pagename, pi):
451 """
452 Invoke getProcessingInstructionVersion with rev=None
453 """
454 return self.xmlrpc_getProcessingInstructionVersion(pagename, rev=None, pi=pi)
455
456 def xmlrpc_getProcessingInstructionVersion(self, pagename, rev, pi):
457 """
458 Returns value of Processing Instruction
459 @param pagename: pagename (utf-8)
460 @param rev: revision number (int)
461 @param pi: PI key
462 """
463 # User may read page?
464 if not self.request.user.may.read(pagename):
465 return self.notAllowedFault()
466 if rev is not None:
467 page = Page(self.request, pagename, rev=rev)
468 else:
469 page = Page(self.request, pagename)
470 if not page.exists():
471 return xmlrpclib.Fault("NOT_EXIST", "Page does not exist.")
472 if pi is None:
473 return xmlrpclib.Fault("NOT_EXIST", "Processing Instruction not given.")
474 try:
475 instruction = page.pi[pi]
476 except KeyError:
477 return xmlrpclib.Fault("NOT_EXIST", "Processing Instruction does not exist.")
478 return self._outstr(instruction)
449 479
450 def xmlrpc_getPage(self, pagename): 480 def xmlrpc_getPage(self, pagename):
451 """ 481 """
452 Invoke xmlrpc_getPageVersion with rev=None 482 Invoke xmlrpc_getPageVersion with rev=None
453 """ 483 """