annotate 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
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
637
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
3 MoinMoin - Wiki XMLRPC v1 and v2 Interface + plugin extensions
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1977
abcbc20e8f8f raise unzip_attachments_count to 101, some other minor changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1960
diff changeset
5 Parts of this code are based on Juergen Hermann's wikirpc.py,
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 Les Orchard's "xmlrpc.cgi" and further work by Gustavo Niemeyer.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 See http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=WikiRPCInterface
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 and http://www.decafbad.com/twiki/bin/view/Main/XmlRpcToWiki
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10 for specs on many of the functions here.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 See also http://www.jspwiki.org/Wiki.jsp?page=WikiRPCInterface2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 for the new stuff.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 The main difference between v1 and v2 is that v2 relies on utf-8
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 as transport encoding. No url-encoding and no base64 anymore, except
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17 when really necessary (like for transferring binary files like
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 attachments maybe).
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
20 @copyright: 2003-2009 MoinMoin:ThomasWaldmann,
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
21 2004-2006 MoinMoin:AlexanderSchremmer,
5362
8fc12793ba3e xmlrpc: process attachname in get and put Attachment similiar
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5345
diff changeset
22 2007-2009 MoinMoin:ReimarBauer
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 @license: GNU GPL, see COPYING for details
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 """
637
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
25 from MoinMoin.util import pysupport
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
26
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
27 modules = pysupport.getPackageModules(__file__)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
29 import os, sys, time, xmlrpclib
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30
3281
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
31 from MoinMoin import log
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
32 logging = log.getLogger(__name__)
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
33
4208
10132d2696dc Fix tests: make XMLRPC use the new authentication functions
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4183
diff changeset
34 from MoinMoin import auth, config, user, wikiutil
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35 from MoinMoin.Page import Page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36 from MoinMoin.PageEditor import PageEditor
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37 from MoinMoin.logfile import editlog
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
38 from MoinMoin.action import AttachFile
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
39 from MoinMoin import caching
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
40
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
41
3281
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
42 logging_tearline = '- XMLRPC %s ' + '-' * 40
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
43
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 class XmlRpcBase:
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
45 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
46 XMLRPC base class with common functionality of wiki xmlrpc v1 and v2
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
47 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 def __init__(self, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50 Initialize an XmlRpcBase object.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 @param request: the request object
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53 self.request = request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54 self.version = None # this has to be defined in derived class
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55 self.cfg = request.cfg
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 #############################################################################
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
58 ### Helper functions
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 def _instr(self, text):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
62 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
63 Convert inbound string.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
64
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
65 @param text: the text to convert (encoded str or unicode)
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
66 @rtype: unicode
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
67 @return: text as unicode
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68 """
1072
c1f5ee67a02b use exception class instead of string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
69 raise NotImplementedError("please implement _instr in derived class")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
70
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
71 def _outstr(self, text):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
72 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
73 Convert outbound string.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
74
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
75 @param text: the text to convert (encoded str or unicode)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
76 @rtype: str
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
77 @return: text as encoded str
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
78 """
1072
c1f5ee67a02b use exception class instead of string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
79 raise NotImplementedError("please implement _outstr in derived class")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
80
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 def _inlob(self, text):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
82 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
83 Convert inbound base64-encoded utf-8 to Large OBject.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
84
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
85 @param text: the text to convert
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
86 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 @return: text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
88 """
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
89 text = text.data # this is a already base64-decoded 8bit string
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
90 text = unicode(text, 'utf-8')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
91 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
92
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
93 def _outlob(self, text):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
94 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
95 Convert outbound Large OBject to base64-encoded utf-8.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
96
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
97 @param text: the text, either unicode or utf-8 string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
98 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
99 @return: xmlrpc Binary object
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
100 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
101 if isinstance(text, unicode):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
102 text = text.encode('utf-8')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
103 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
104 if config.charset != 'utf-8':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
105 text = unicode(text, config.charset).encode('utf-8')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
106 return xmlrpclib.Binary(text)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
107
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
108 def _dump_exc(self):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
109 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
110 Convert an exception to a string.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
111
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
112 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
113 @return: traceback as string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
114 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
115 import traceback
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
116
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117 return "%s: %s\n%s" % (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
118 sys.exc_info()[0],
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
119 sys.exc_info()[1],
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
120 '\n'.join(traceback.format_tb(sys.exc_info()[2])),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
121 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
122
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
123 def process(self):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
124 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
125 xmlrpc v1 and v2 dispatcher
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
126 """
4241
c27f6cb0892e Fixed: XMLRPC calls
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4210
diff changeset
127 request = self.request
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
128 try:
2799
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
129 if 'xmlrpc' in self.request.cfg.actions_excluded:
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
130 # we do not handle xmlrpc v1 and v2 differently
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
131 response = xmlrpclib.Fault(1, "This moin wiki does not allow xmlrpc method calls.")
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
132 else:
5515
28d3928f6e6e xmlrpc: invalidate user object setup by the moin session/auth code (details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3690
diff changeset
133 # overwrite any user there might be, if you need a valid user for
28d3928f6e6e xmlrpc: invalidate user object setup by the moin session/auth code (details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3690
diff changeset
134 # xmlrpc, you have to use multicall and getAuthToken / applyAuthToken
5517
2c992293ece4 merged moin/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5419 5516
diff changeset
135 request.user = user.User(request, auth_method='xmlrpc:invalid')
5515
28d3928f6e6e xmlrpc: invalidate user object setup by the moin session/auth code (details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3690
diff changeset
136
5660
8ed0f132fb44 remove request.in_data, simplifies code (use request.read() for same effect)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5517
diff changeset
137 data = request.read()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
138
3348
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
139 try:
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
140 params, method = xmlrpclib.loads(data)
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
141 except:
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
142 # if anything goes wrong here, we want to see the raw data:
3349
81697026ee86 better xmlrpc debugging, show length of raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3348
diff changeset
143 logging.debug("Length of raw data: %d bytes" % len(data))
3348
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
144 logging.debug(logging_tearline % 'request raw data begin')
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
145 logging.debug('%r' % data)
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
146 logging.debug(logging_tearline % 'request raw data end')
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
147 raise
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
148
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
149 logging.debug(logging_tearline % 'request parsed data begin')
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
150 logging.debug('%s(%r)' % (method, params))
9d726e040fda better xmlrpc debugging, show raw request data in case of loads exceptions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3281
diff changeset
151 logging.debug(logging_tearline % 'request parsed data end')
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
152
2799
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
153 response = self.dispatch(method, params)
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
154 except:
3281
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
155 logging.exception("An exception occurred (this is also sent as fault response to the client):")
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
156 # report exception back to client
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
157 response = xmlrpclib.dumps(xmlrpclib.Fault(1, self._dump_exc()))
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
158 else:
3281
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
159 logging.debug(logging_tearline % 'response begin')
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
160 logging.debug(response)
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
161 logging.debug(logging_tearline % 'response end')
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
162
1160
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
163 if isinstance(response, xmlrpclib.Fault):
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
164 response = xmlrpclib.dumps(response)
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
165 else:
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
166 # wrap response in a singleton tuple
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
167 response = (response, )
1160
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
168 # serialize it
3690
a1a9ac307c0e SyncPages, xmlrpc.process: bug fix for WikiSyncMissingInterWikiNameOnRemoteSide (thanks to Alexander Schremmer)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3672
diff changeset
169 response = xmlrpclib.dumps(response, methodresponse=1, allow_none=True)
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
170
4241
c27f6cb0892e Fixed: XMLRPC calls
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4210
diff changeset
171 request = request.request
c27f6cb0892e Fixed: XMLRPC calls
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4210
diff changeset
172 request.content_type = 'text/xml'
c27f6cb0892e Fixed: XMLRPC calls
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4210
diff changeset
173 request.data = response
c27f6cb0892e Fixed: XMLRPC calls
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4210
diff changeset
174 return request
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
175
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
176 def dispatch(self, method, params):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
177 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
178 call dispatcher - for method==xxx it either locates a method called
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
179 xmlrpc_xxx or loads a plugin from plugin/xmlrpc/xxx.py
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
180 """
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
181 method = method.replace(".", "_")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
182
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
183 try:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
184 fn = getattr(self, 'xmlrpc_' + method)
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
185 except AttributeError:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
186 try:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
187 fn = wikiutil.importPlugin(self.request.cfg, 'xmlrpc',
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
188 method, 'execute')
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
189 except wikiutil.PluginMissingError:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
190 response = xmlrpclib.Fault(1, "No such method: %s." %
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
191 method)
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
192 else:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
193 response = fn(self, *params)
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
194 else:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
195 response = fn(*params)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
196
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
197 return response
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
198
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
199 # Common faults -----------------------------------------------------
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
200
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
201 def notAllowedFault(self):
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
202 return xmlrpclib.Fault(1, "You are not allowed to read this page.")
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
203
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
204 def noSuchPageFault(self):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
205 return xmlrpclib.Fault(1, "No such page was found.")
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
206
3546
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
207 def noLogEntryFault(self):
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
208 return xmlrpclib.Fault(1, "No log entry was found.")
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
209
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
210 #############################################################################
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
211 ### System methods
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
212 #############################################################################
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
213
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
214 def xmlrpc_system_multicall(self, call_list):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
215 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
216 system.multicall([{'methodName': 'add', 'params': [2, 2]}, ...]) => [[4], ...]
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
217
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
218 Allows the caller to package multiple XML-RPC calls into a single
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
219 request.
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
220
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
221 See http://www.xmlrpc.com/discuss/msgReader$1208
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
222
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
223 Copied from SimpleXMLRPCServer.py
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
224 """
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
225
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
226 results = []
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
227 for call in call_list:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
228 method_name = call['methodName']
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
229 params = call['params']
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
230
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
231 try:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
232 # XXX A marshalling error in any response will fail the entire
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
233 # multicall. If someone cares they should fix this.
2126
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
234 result = self.dispatch(method_name, params)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
235
2126
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
236 if not isinstance(result, xmlrpclib.Fault):
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
237 results.append([result])
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
238 else:
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
239 results.append(
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
240 {'faultCode': result.faultCode,
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
241 'faultString': result.faultString}
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
242 )
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
243 except:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
244 results.append(
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
245 {'faultCode': 1,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
246 'faultString': "%s:%s" % (sys.exc_type, sys.exc_value)}
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
247 )
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
248
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
249 return results
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
250
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
251 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
252 ### Interface implementation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
253 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
254
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
255 def xmlrpc_getRPCVersionSupported(self):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
256 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
257 Returns version of the Wiki xmlrpc API.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
258
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
259 @rtype: int
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
260 @return: 1 or 2 (wikirpc version)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
261 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
262 return self.version
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
263
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
264 def xmlrpc_getAllPages(self):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
265 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
266 Get all pages readable by current user
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
267
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
268 @rtype: list
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
269 @return: a list of all pages.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
270 """
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
271
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
272 # the official WikiRPC interface is implemented by the extended method as well
1040
ad101845642b Call the Ex method from the original method, fixed a bug in the Ex method (wikirpc)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1035
diff changeset
273 return self.xmlrpc_getAllPagesEx()
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
274
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
275
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
276 def xmlrpc_getAllPagesEx(self, opts=None):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
277 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
278 Get all pages readable by current user. Not an WikiRPC method.
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
279
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
280 @param opts: dictionary that can contain the following arguments:
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
281 include_system:: set it to false if you do not want to see system pages
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
282 include_revno:: set it to True if you want to have lists with [pagename, revno]
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
283 include_deleted:: set it to True if you want to include deleted pages
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
284 exclude_non_writable:: do not include pages that the current user may not write to
1262
16bed977b054 Added support for underlay page ignore and prefix filtering in getAllPagesEx,
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1260
diff changeset
285 include_underlay:: return underlay pagenames as well
16bed977b054 Added support for underlay page ignore and prefix filtering in getAllPagesEx,
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1260
diff changeset
286 prefix:: the page name must begin with this prefix to be included
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
287 mark_deleted:: returns the revision number -rev_no if the page was deleted.
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
288 Makes only sense if you enable include_revno and include_deleted.
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
289 @rtype: list
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
290 @return: a list of all pages.
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
291 """
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
292 from MoinMoin.wikisync import normalise_pagename
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
293 options = {"include_system": True, "include_revno": False, "include_deleted": False,
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
294 "exclude_non_writable": False, "include_underlay": True, "prefix": "",
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
295 "pagelist": None, "mark_deleted": False}
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
296 if opts is not None:
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
297 options.update(opts)
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
298
1040
ad101845642b Call the Ex method from the original method, fixed a bug in the Ex method (wikirpc)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1035
diff changeset
299 if not options["include_system"]:
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
300 p_filter = lambda name: not wikiutil.isSystemPage(self.request, name)
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
301 else:
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
302 p_filter = lambda name: True
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
303
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
304 if options["exclude_non_writable"]:
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
305 p_filter = lambda name, p_filter=p_filter: p_filter(name) and self.request.user.may.write(name)
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
306
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
307 if options["prefix"] or options["pagelist"]:
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
308 def p_filter(name, p_filter=p_filter, prefix=(options["prefix"] or ""), pagelist=options["pagelist"]):
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
309 if not p_filter(name):
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
310 return False
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
311 n_name = normalise_pagename(name, prefix)
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
312 if not n_name:
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
313 return False
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
314 if not pagelist:
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
315 return True
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
316 return n_name in pagelist
1262
16bed977b054 Added support for underlay page ignore and prefix filtering in getAllPagesEx,
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1260
diff changeset
317
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
318 pagelist = self.request.rootpage.getPageList(filter=p_filter, exists=not options["include_deleted"],
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
319 include_underlay=options["include_underlay"],
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
320 return_objects=options["include_revno"])
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
321
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
322 if options['include_revno']:
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
323 pages = []
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
324 for page in pagelist:
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
325 revno = page.get_real_rev()
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
326 if options["mark_deleted"] and not page.exists():
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
327 revno = -revno
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
328 pages.append([self._outstr(page.page_name), revno])
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
329 return pages
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
330 else:
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
331 return [self._outstr(page) for page in pagelist]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
332
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
333 def xmlrpc_getRecentChanges(self, date):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
334 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
335 Get RecentChanges since date
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
336
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
337 @param date: date since when rc will be listed
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
338 @rtype: list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
339 @return: a list of changed pages since date, which should be in
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
340 UTC. The result is a list, where each element is a struct:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
341 * name (string) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
342 Name of the page. The name is in UTF-8.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
343 * lastModified (date) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
344 Date of last modification, in UTC.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
345 * author (string) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
346 Name of the author (if available). UTF-8.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
347 * version (int) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
348 Current version.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
349 """
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
350
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
351 return_items = []
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
352
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
353 edit_log = editlog.EditLog(self.request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
354 for log in edit_log.reverse():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
355 # get last-modified UTC (DateTime) from log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
356 gmtuple = tuple(time.gmtime(wikiutil.version2timestamp(log.ed_time_usecs)))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
357 lastModified_date = xmlrpclib.DateTime(gmtuple)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
358
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
359 # skip if older than "date"
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
360 if lastModified_date < date:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
361 break
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
362
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
363 # skip if knowledge not permitted
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
364 if not self.request.user.may.read(log.pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
365 continue
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
366
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
367 # get page name (str) from log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
368 pagename_str = self._outstr(log.pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
369
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
370 # get user name (str) from log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
371 author_str = log.hostname
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
372 if log.userid:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
373 userdata = user.User(self.request, log.userid)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
374 if userdata.name:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
375 author_str = userdata.name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
376 author_str = self._outstr(author_str)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
377
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
378 return_item = {'name': pagename_str,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
379 'lastModified': lastModified_date,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
380 'author': author_str,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
381 'version': int(log.rev) }
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
382 return_items.append(return_item)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
383
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
384 return return_items
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
385
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
386 def xmlrpc_getPageInfo(self, pagename):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
387 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
388 Invoke xmlrpc_getPageInfoVersion with rev=None
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
389 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
390 return self.xmlrpc_getPageInfoVersion(pagename, rev=None)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
391
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
392 def xmlrpc_getPageInfoVersion(self, pagename, rev):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
393 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
394 Return page information for specific revision
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
395
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
396 @param pagename: the name of the page (utf-8)
1799
06ce4843b9b5 remove some XXX strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1793
diff changeset
397 @param rev: revision to get info about (int)
06ce4843b9b5 remove some XXX strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1793
diff changeset
398 @rtype: dict
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
399 @return: page information
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
400 * name (string): the canonical page name, UTF-8.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 * lastModified (date): Last modification date, UTC.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
402 * author (string): author name, UTF-8.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403 * version (int): current version
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
404
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
405 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
406 pn = self._instr(pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
407
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
408 # User may read this page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
409 if not self.request.user.may.read(pn):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
410 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
411
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
412 if rev is not None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
413 page = Page(self.request, pn, rev=rev)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
414 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
415 page = Page(self.request, pn)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
416 rev = page.current_rev()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
417
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
418 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
419 if not page.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
420 return self.noSuchPageFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
421
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
422 # Get page info
3546
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
423 edit_info = page.edit_info()
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
424 if not edit_info:
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
425 return self.noLogEntryFault()
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
426
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
427 mtime = wikiutil.version2timestamp(long(edit_info['timestamp'])) # must be long for py 2.2.x
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
428 gmtuple = tuple(time.gmtime(mtime))
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
429
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
430 version = rev # our new rev numbers: 1,2,3,4,....
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
431
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
432 #######################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
433 # BACKWARDS COMPATIBILITY CODE - remove when 1.2.x is regarded stone age
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
434 # as we run a feed for BadContent on MoinMaster, we want to stay
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
435 # compatible here for a while with 1.2.x moins asking us for BadContent
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
436 # 1.3 uses the lastModified field for checking for updates, so it
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
437 # should be no problem putting the old UNIX timestamp style of version
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
438 # number in the version field
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
439 if self.request.cfg.sitename == 'MoinMaster' and pagename == 'BadContent':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
440 version = int(mtime)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
441 #######################################################################
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
442
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
443 return {
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
444 'name': self._outstr(page.page_name),
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
445 'lastModified': xmlrpclib.DateTime(gmtuple),
3546
c9494979fe7a xmlrpc getPageInfoVersion fixed / Page.last_edit() fixed and renamed to edit_info(). Works correctly now for current revision and supports old revisions.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3435
diff changeset
446 'author': self._outstr(edit_info['editor']),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
447 'version': version,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
448 }
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
449
5816
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
450 def xmlrpc_getProcessingInstruction(self, pagename, pi):
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
451 """
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
452 Invoke getProcessingInstructionVersion with rev=None
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
453 """
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
454 return self.xmlrpc_getProcessingInstructionVersion(pagename, rev=None, pi=pi)
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
455
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
456 def xmlrpc_getProcessingInstructionVersion(self, pagename, rev, pi):
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
457 """
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
458 Returns value of Processing Instruction
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
459 @param pagename: pagename (utf-8)
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
460 @param rev: revision number (int)
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
461 @param pi: PI key
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
462 """
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
463 # User may read page?
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
464 if not self.request.user.may.read(pagename):
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
465 return self.notAllowedFault()
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
466 if rev is not None:
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
467 page = Page(self.request, pagename, rev=rev)
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
468 else:
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
469 page = Page(self.request, pagename)
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
470 if not page.exists():
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
471 return xmlrpclib.Fault("NOT_EXIST", "Page does not exist.")
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
472 if pi is None:
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
473 return xmlrpclib.Fault("NOT_EXIST", "Processing Instruction not given.")
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
474 try:
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
475 instruction = page.pi[pi]
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
476 except KeyError:
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
477 return xmlrpclib.Fault("NOT_EXIST", "Processing Instruction does not exist.")
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
478 return self._outstr(instruction)
b661a89ef0be xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5815
diff changeset
479
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
480 def xmlrpc_getPage(self, pagename):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
481 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
482 Invoke xmlrpc_getPageVersion with rev=None
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
483 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
484 return self.xmlrpc_getPageVersion(pagename, rev=None)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
485
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
486 def xmlrpc_getPageVersion(self, pagename, rev):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
487 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
488 Get raw text from specific revision of pagename
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
489
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
490 @param pagename: pagename (utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
491 @param rev: revision number (int)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
492 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
493 @return: utf-8 encoded page data
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
494 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
495 pagename = self._instr(pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
496
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
497 # User may read page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
498 if not self.request.user.may.read(pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
499 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
500
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
501 if rev is not None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
502 page = Page(self.request, pagename, rev=rev)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
503 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
504 page = Page(self.request, pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
505
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
506 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
507 if not page.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
508 return self.noSuchPageFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
509
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
510 # Return page raw text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
511 if self.version == 2:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
512 return self._outstr(page.get_raw_body())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
513 elif self.version == 1:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
514 return self._outlob(page.get_raw_body())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
515
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
516 def xmlrpc_getPageHTML(self, pagename):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
517 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
518 Invoke xmlrpc_getPageHTMLVersion with rev=None
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
519 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
520 return self.xmlrpc_getPageHTMLVersion(pagename, rev=None)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
521
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
522 def xmlrpc_getPageHTMLVersion(self, pagename, rev):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
523 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
524 Get HTML of from specific revision of pagename
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
525
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
526 @param pagename: the page name (utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
527 @param rev: revision number (int)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
528 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
529 @return: page in rendered HTML (utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
530 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
531 pagename = self._instr(pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
532
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
533 # User may read page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
534 if not self.request.user.may.read(pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
535 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
536
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
537 if rev is not None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
538 page = Page(self.request, pagename, rev=rev)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
539 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
540 page = Page(self.request, pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
541
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
542 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
543 if not page.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
544 return self.noSuchPageFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
545
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
546 # Render page into a buffer
1777
ed44b93599b5 remove unneeded request param from page.send_page()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1385
diff changeset
547 result = self.request.redirectedOutput(page.send_page, content_only=1)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
548
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
549 # Return rendered page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
550 if self.version == 2:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
551 return self._outstr(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
552 elif self.version == 1:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
553 return xmlrpclib.Binary(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
554
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
555 def xmlrpc_listLinks(self, pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
556 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
557 list links for a given page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
558 @param pagename: the page name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
559 @rtype: list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
560 @return: links of the page, structs, with the following elements
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
561 * name (string) : The page name or URL the link is to, UTF-8 encoding.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
562 * type (int) : The link type. Zero (0) for internal Wiki
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
563 link, one (1) for external link (URL - image link, whatever).
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
564 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
565 pagename = self._instr(pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
566
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
567 # User may read page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
568 if not self.request.user.may.read(pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
569 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
570
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
571 page = Page(self.request, pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
572
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
573 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
574 if not page.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
575 return self.noSuchPageFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
576
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
577 links_out = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
578 for link in page.getPageLinks(self.request):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
579 links_out.append({'name': self._outstr(link), 'type': 0 })
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
580 return links_out
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
581
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
582 def xmlrpc_putPage(self, pagename, pagetext):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
583 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
584 save a page / change a page to a new text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
585 @param pagename: the page name (unicode or utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
586 @param pagetext: the new page text (content, unicode or utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
587 @rtype: bool
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
588 @return: True on success
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
589 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
590
2795
f24afde03048 xmlrpc_putPage: call depends on acls and wiki auth or http auth, identical to wikisync, wiki auth see following example
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2698
diff changeset
591 pagename = self._instr(pagename)
5316
5060bec6a284 xmlrpc.__init__: bug fix for MoinMoinBugs/1.6XmlRpcPutPagePagenameEscape
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4628
diff changeset
592 pagename = wikiutil.normalize_pagename(pagename, self.cfg)
3049
ed9b1e5cf0e1 fix MoinMoinBugs/XmlRpcPutPageAllowsEmptyPageName (thanks to Jonas Wagner) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2916
diff changeset
593 if not pagename:
ed9b1e5cf0e1 fix MoinMoinBugs/XmlRpcPutPageAllowsEmptyPageName (thanks to Jonas Wagner) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2916
diff changeset
594 return xmlrpclib.Fault("INVALID", "pagename can't be empty")
ed9b1e5cf0e1 fix MoinMoinBugs/XmlRpcPutPageAllowsEmptyPageName (thanks to Jonas Wagner) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2916
diff changeset
595
2916
06547d7df727 fix putPage comment
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2915
diff changeset
596 # check ACLs
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
597 if not self.request.user.may.write(pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
598 return xmlrpclib.Fault(1, "You are not allowed to edit this page")
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
599
5672
203afc609f8a xmlrpc: Disable editor backup for putPage, renamePage and revertPage because if pages become uploaded by xmlrpc then the draft cache arena can fast increase to a big cache file size. On each of these methods called and on each server process the cache file must be loaded and processed. This can costs much memory and decreases speed of these calls.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5660
diff changeset
600 page = PageEditor(self.request, pagename, do_editor_backup=0)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
601 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
602 if self.version == 2:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
603 newtext = self._instr(pagetext)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
604 elif self.version == 1:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
605 newtext = self._inlob(pagetext)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
606 msg = page.saveText(newtext, 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
607 except page.SaveError, msg:
3281
d519735ca765 xmlrpc: use logging module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
608 logging.error("SaveError: %s" % msg)
2915
05d90815b0f9 xmlrpc: fault on save errors
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2914
diff changeset
609 return xmlrpclib.Fault(1, "%s" % msg)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
610
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
611 # Update pagelinks cache
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
612 page.getPageLinks(self.request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
613
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
614 return xmlrpclib.Boolean(1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
615
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
616 def xmlrpc_renamePage(self, pagename, newpagename):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
617 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
618 Renames a page <pagename> to <newpagename>.
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
619
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
620 @param pagename: the page name (unicode or utf-8)
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
621 @param newpagename: the new pagename (unicode or utf-8)
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
622 @rtype: bool
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
623 @return: True on success
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
624 """
5360
71d0252a92a9 xmlrpc.renamePage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5359
diff changeset
625
71d0252a92a9 xmlrpc.renamePage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5359
diff changeset
626 pagename = self._instr(pagename)
71d0252a92a9 xmlrpc.renamePage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5359
diff changeset
627 pagename = wikiutil.normalize_pagename(pagename, self.cfg)
71d0252a92a9 xmlrpc.renamePage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5359
diff changeset
628 if not pagename:
71d0252a92a9 xmlrpc.renamePage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5359
diff changeset
629 return xmlrpclib.Fault("INVALID", "pagename can't be empty")
71d0252a92a9 xmlrpc.renamePage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5359
diff changeset
630
71d0252a92a9 xmlrpc.renamePage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5359
diff changeset
631 # check ACLs
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
632 if not (self.request.user.may.delete(pagename) and self.request.user.may.write(newpagename)):
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
633 return xmlrpclib.Fault(1, "You are not allowed to rename this page")
5672
203afc609f8a xmlrpc: Disable editor backup for putPage, renamePage and revertPage because if pages become uploaded by xmlrpc then the draft cache arena can fast increase to a big cache file size. On each of these methods called and on each server process the cache file must be loaded and processed. This can costs much memory and decreases speed of these calls.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5660
diff changeset
634 editor = PageEditor(self.request, pagename, do_editor_backup=0)
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
635
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
636 try:
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
637 editor.renamePage(newpagename)
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
638 except PageEditor.SaveError, error:
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
639 return xmlrpclib.Fault(1, "Rename failed: %s" % (str(error), ))
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
640
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
641 return xmlrpclib.Boolean(1)
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
642
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
643 def xmlrpc_revertPage(self, pagename, revision):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
644 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
645 Revert a page to previous revision
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
646
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
647 This is mainly intended to be used by the jabber bot.
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
648
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
649 @param pagename: the page name (unicode or utf-8)
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
650 @param revision: revision to revert to
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
651 @rtype: bool
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
652 @return: True on success
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
653
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
654 """
5394
cbd72078ad91 xmlrpc.revertPage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5362
diff changeset
655
cbd72078ad91 xmlrpc.revertPage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5362
diff changeset
656 pagename = self._instr(pagename)
cbd72078ad91 xmlrpc.revertPage: convert pagename to internal representation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5362
diff changeset
657
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
658 if not self.request.user.may.write(pagename):
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
659 return xmlrpclib.Fault(1, "You are not allowed to edit this page")
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
660
2698
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
661 rev = int(self._instr(revision))
5672
203afc609f8a xmlrpc: Disable editor backup for putPage, renamePage and revertPage because if pages become uploaded by xmlrpc then the draft cache arena can fast increase to a big cache file size. On each of these methods called and on each server process the cache file must be loaded and processed. This can costs much memory and decreases speed of these calls.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5660
diff changeset
662 editor = PageEditor(self.request, pagename, do_editor_backup=0)
2698
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
663
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
664 try:
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
665 editor.revertPage(rev)
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
666 except PageEditor.SaveError, error:
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
667 return xmlrpclib.Fault(1, "Revert failed: %s" % (str(error), ))
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
668
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
669 return xmlrpclib.Boolean(1)
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
670
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
671 def xmlrpc_searchPages(self, query_string):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
672 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
673 Searches pages for query_string.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
674 Returns a list of tuples (foundpagename, context)
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
675 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
676 from MoinMoin import search
919
5469c8b911a4 Splitting out MoinMoin/search.py to MoinMoin/search/*.py
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 787
diff changeset
677 results = search.searchPages(self.request, query_string)
622
8fba6d15a2f5 make request.(html_)formatter available early and use it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 101
diff changeset
678 results.formatter = self.request.html_formatter
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
679 results.request = self.request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
680 return [(self._outstr(hit.page_name),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
681 self._outstr(results.formatContext(hit, 180, 1)))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
682 for hit in results.hits]
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
683
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
684 def xmlrpc_searchPagesEx(self, query_string, search_type, length, case, mtime, regexp):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
685 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
686 Searches pages for query_string - extended version for compatibility
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
687
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
688 This function, in contrary to searchPages(), doesn't return HTML-formatted data.
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
689
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
690 @param query_string: term to search for
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
691 @param search_type: "text" or "title" search
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
692 @param length: length of context preview (in characters)
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
693 @param case: should the search be case sensitive?
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
694 @param mtime: only output pages modified after mtime
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
695 @param regexp: should the query_string be treates as a regular expression?
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
696 @return: (page name, context preview, page url)
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
697 """
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
698 from MoinMoin import search
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
699 from MoinMoin.formatter.text_plain import Formatter
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
700
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
701 kwargs = {"sort": "page_name", "case": case, "regex": regexp}
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
702 if search_type == "title":
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
703 kwargs["titlesearch"] = True
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
704
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
705 results = search.searchPages(self.request, query_string, **kwargs)
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
706 results.formatter = Formatter(self.request)
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
707 results.request = self.request
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
708
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
709 return [(self._outstr(hit.page_name),
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
710 self._outstr(results.formatContext(hit, length, 1)),
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3175
diff changeset
711 self.request.getQualifiedURL(hit.page.url(self.request, {})))
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
712 for hit in results.hits]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
713
782
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
714 def xmlrpc_getMoinVersion(self):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
715 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
716 Returns a tuple of the MoinMoin version:
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
717 (project, release, revision)
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
718 """
782
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
719 from MoinMoin import version
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
720 return (version.project, version.release, version.revision)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
721
2181
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
722
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
723 # user profile data transfer
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
724
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
725 def xmlrpc_getUserProfile(self):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
726 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
727 Return the user profile data for the current user.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
728 Use this in a single multicall after applyAuthToken.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
729 If we have a valid user, returns a dict of items from user profile.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
730 Otherwise, return an empty dict.
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
731 """
2181
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
732 u = self.request.user
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
733 if not u.valid:
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
734 userdata = {}
1951
a05a3b447db5 interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
735 else:
a05a3b447db5 interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
736 userdata = dict(u.persistent_items())
2181
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
737 return userdata
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
738
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
739 def xmlrpc_getUserLanguageByJID(self, jid):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
740 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
741 Returns user's language given his/her Jabber ID
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
742
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
743 It makes no sense to consider this a secret, right? Therefore
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
744 an authentication token is not required. We return a default
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
745 of "en" if user is not found.
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
746
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
747 TODO: surge protection? Do we fear account enumeration?
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
748 """
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
749 retval = "en"
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
750 u = user.get_by_jabber_id(self.request, jid)
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
751 if u:
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
752 retval = u.language
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
753
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
754 return retval
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
755
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
756 # authorization methods
2181
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
757
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
758 def xmlrpc_getAuthToken(self, username, password, *args):
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
759 """
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
760 Returns a token which can be used for authentication
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
761 in other XMLRPC calls. If the token is empty, the username
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
762 or the password were wrong.
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
763
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
764 Implementation note: token is same as cookie content would be for http session
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
765 """
4208
10132d2696dc Fix tests: make XMLRPC use the new authentication functions
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4183
diff changeset
766 request = self.request
10132d2696dc Fix tests: make XMLRPC use the new authentication functions
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4183
diff changeset
767 request.session = request.cfg.session_service.get_session(request)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
768
4208
10132d2696dc Fix tests: make XMLRPC use the new authentication functions
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4183
diff changeset
769 u = auth.setup_from_session(request, request.session)
10132d2696dc Fix tests: make XMLRPC use the new authentication functions
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4183
diff changeset
770 u = auth.handle_login(request, u, username=username, password=password)
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
771
2009
1b14cc05a54a refactor authentication and split out session handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 1977
diff changeset
772 if u and u.valid:
4529
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
773 request.user = u
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
774 request.cfg.session_service.finalize(request, request.session)
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
775 return request.session.sid
955
05b7c435a3d6 Implemented token functions that use the normal moin id
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 954
diff changeset
776 else:
956
413263beeafc Changed auth token api to authenticate only (no calls because it would not work with MultiCall otherwise
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 955
diff changeset
777 return ""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
778
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
779 def xmlrpc_getJabberAuthToken(self, jid, secret):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
780 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
781 Returns a token which can be used for authentication.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
782
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
783 This token can be used in other XMLRPC calls. Generation of
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
784 token depends on user's JID and a secret shared between wiki
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
785 and Jabber bot.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
786
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
787 @param jid: a bare Jabber ID
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
788 """
3873
e5a9570d3001 secrets configuration refactored - see the snippet for an example usage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3690
diff changeset
789 if self.cfg.secrets['jabberbot'] != secret:
5419
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
790 logging.warning("getJabberAuthToken: got wrong secret %r" % secret)
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
791 return ""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
792
5419
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
793 request = self.request
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
794 request.session = request.cfg.session_service.get_session(request)
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
795 logging.debug("getJabberAuthToken: got session %r" % request.session)
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
796
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
797 u = user.get_by_jabber_id(request, jid) # XXX is someone talking to use from a jid we have stored in
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
798 # XXX some user profile enough to authenticate him as that user?
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
799 logging.debug("getJabberAuthToken: got user %r" % u)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
800
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
801 if u and u.valid:
5419
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
802 u.auth_method = 'moin' # XXX fake 'moin' login so the check for known login methods succeeds
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
803 # XXX if not patched, u.auth_method is 'internal', but that is not accepted either
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
804 # TODO this should be done more cleanly, somehow
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
805 request.user = u
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
806 request.cfg.session_service.finalize(request, request.session)
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
807 logging.debug("getJabberAuthToken: returning sid %r" % request.session.sid)
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
808 return request.session.sid
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
809 else:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
810 return ""
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
811
956
413263beeafc Changed auth token api to authenticate only (no calls because it would not work with MultiCall otherwise
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 955
diff changeset
812 def xmlrpc_applyAuthToken(self, auth_token):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
813 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
814 Applies the auth token and thereby authenticates the user.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
815 """
3435
1a95fc180bdd xmlrpc applyAuthToken: give good error msg for empty token, avoid CachingError 'is a directory' (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3388
diff changeset
816 if not auth_token:
1a95fc180bdd xmlrpc applyAuthToken: give good error msg for empty token, avoid CachingError 'is a directory' (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3388
diff changeset
817 return xmlrpclib.Fault("INVALID", "Empty token.")
1a95fc180bdd xmlrpc applyAuthToken: give good error msg for empty token, avoid CachingError 'is a directory' (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3388
diff changeset
818
4529
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
819 request = self.request
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
820 request.session = request.cfg.session_service.get_session(request, auth_token)
5419
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
821 logging.debug("applyAuthToken: got session %r" % request.session)
4529
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
822 u = auth.setup_from_session(request, request.session)
5419
5eaec9412317 fixed xmlrpc auth calls used by jabberbot (needs more work, see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5398
diff changeset
823 logging.debug("applyAuthToken: got user %r" % u)
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
824
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
825 if u and u.valid:
3388
8ff8bc7dea20 xmlrpc.__init__: fixed missing user xmlrpc_applyAuthToken
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3349
diff changeset
826 self.request.user = u
956
413263beeafc Changed auth token api to authenticate only (no calls because it would not work with MultiCall otherwise
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 955
diff changeset
827 return "SUCCESS"
955
05b7c435a3d6 Implemented token functions that use the normal moin id
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 954
diff changeset
828 else:
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
829 return xmlrpclib.Fault("INVALID", "Invalid token.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
830
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
831
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
832 def xmlrpc_deleteAuthToken(self, auth_token):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
833 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
834 Delete the given auth token.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
835 """
4529
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
836 if not auth_token:
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
837 return xmlrpclib.Fault("INVALID", "Empty token.")
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
838
4529
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
839 request = self.request
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
840 request.session = request.cfg.session_service.get_session(request, auth_token)
002c21b10561 fix / finish xmlrpc auth token (session) code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4252
diff changeset
841 request.cfg.session_service.destroy_session(request, request.session)
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
842
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
843 return "SUCCESS"
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
844
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
845
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
846 # methods for wiki synchronization
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
847
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
848 def xmlrpc_getDiff(self, pagename, from_rev, to_rev, n_name=None):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
849 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
850 Gets the binary difference between two page revisions.
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
851
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
852 @param pagename: unicode string qualifying the page name
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
853
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
854 @param fromRev: integer specifying the source revision. May be None to
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
855 refer to a virtual empty revision which leads to a diff
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
856 containing the whole page.
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
857
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
858 @param toRev: integer specifying the target revision. May be None to
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
859 refer to the current revision. If the current revision is the same
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
860 as fromRev, there will be a special error condition "ALREADY_CURRENT"
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
861
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
862 @param n_name: do a tag check verifying that n_name was the normalised
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
863 name of the last tag
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
864
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
865 If both fromRev and toRev are None, this function acts similar to getPage, i.e. it will diff("",currentRev).
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
866
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
867 @return: Returns a dict:
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
868 * status (not a field, implicit, returned as Fault if not SUCCESS):
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
869 * "SUCCESS" - if the diff could be retrieved successfully
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
870 * "NOT_EXIST" - item does not exist
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
871 * "FROMREV_INVALID" - the source revision is invalid
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
872 * "TOREV_INVALID" - the target revision is invalid
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
873 * "INTERNAL_ERROR" - there was an internal error
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
874 * "INVALID_TAG" - the last tag does not match the supplied normalised name
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
875 * "ALREADY_CURRENT" - this not merely an error condition. It rather means that
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
876 there is no new revision to diff against which is a good thing while
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
877 synchronisation.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
878 * current: the revision number of the current revision (not the one which was diff'ed against)
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
879 * diff: Binary object that transports a zlib-compressed binary diff (see bdiff.py, taken from Mercurial)
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
880 * conflict: if there is a conflict on the page currently
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
881 """
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
882 from MoinMoin.util.bdiff import textdiff, compress
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
883 from MoinMoin.wikisync import TagStore
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
884
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
885 pagename = self._instr(pagename)
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
886 if n_name is not None:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
887 n_name = self._instr(n_name)
787
9d74a2f53323 Merge with main.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 786 758
diff changeset
888
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
889 # User may read page?
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
890 if not self.request.user.may.read(pagename):
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
891 return self.notAllowedFault()
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
892
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
893 def allowed_rev_type(data):
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
894 if data is None:
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
895 return True
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
896 return isinstance(data, int) and data > 0
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
897
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
898 if not allowed_rev_type(from_rev):
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
899 return xmlrpclib.Fault("FROMREV_INVALID", "Incorrect type for from_rev.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
900
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
901 if not allowed_rev_type(to_rev):
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
902 return xmlrpclib.Fault("TOREV_INVALID", "Incorrect type for to_rev.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
903
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
904 currentpage = Page(self.request, pagename)
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
905 if not currentpage.exists():
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
906 return xmlrpclib.Fault("NOT_EXIST", "Page does not exist.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
907
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
908 revisions = currentpage.getRevList()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
909
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
910 if from_rev is not None and from_rev not in revisions:
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
911 return xmlrpclib.Fault("FROMREV_INVALID", "Unknown from_rev.")
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
912 if to_rev is not None and to_rev not in revisions:
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
913 return xmlrpclib.Fault("TOREV_INVALID", "Unknown to_rev.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
914
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
915 # use lambda to defer execution in the next lines
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
916 if from_rev is None:
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
917 oldcontents = lambda: ""
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
918 else:
1074
40b708ecc332 Fixed minor bug in XMLRPC code.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
919 oldpage = Page(self.request, pagename, rev=from_rev)
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
920 oldcontents = lambda: oldpage.get_raw_body_str()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
921
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
922 if to_rev is None:
1250
97e9866e82c7 Fixed minor bug in getDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1161
diff changeset
923 newpage = currentpage
1256
f3c8f750c1fe Another minor unicode bug in getDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1255
diff changeset
924 newcontents = lambda: currentpage.get_raw_body_str()
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
925 else:
1074
40b708ecc332 Fixed minor bug in XMLRPC code.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
926 newpage = Page(self.request, pagename, rev=to_rev)
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
927 newcontents = lambda: newpage.get_raw_body_str()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
928
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
929 if oldcontents() and oldpage.get_real_rev() == newpage.get_real_rev():
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
930 return xmlrpclib.Fault("ALREADY_CURRENT", "There are no changes.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
931
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
932 if n_name is not None:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
933 tags = TagStore(newpage)
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
934 last_tag = tags.get_last_tag()
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
935 if last_tag is not None and last_tag.normalised_name != n_name:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
936 return xmlrpclib.Fault("INVALID_TAG", "The used tag is incorrect because the normalised name does not match.")
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
937
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
938 newcontents = newcontents()
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
939 conflict = wikiutil.containsConflictMarker(newcontents)
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
940 diffblob = xmlrpclib.Binary(compress(textdiff(oldcontents(), newcontents)))
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
941
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
942 return {"conflict": conflict, "diff": diffblob, "diffversion": 1, "current": currentpage.get_real_rev()}
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
943
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
944 def xmlrpc_interwikiName(self):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
945 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
946 Returns the interwiki name and the IWID of the current wiki.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
947 """
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
948 name = self.request.cfg.interwikiname
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
949 iwid = self.request.cfg.iwid
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
950 if name is None:
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
951 return [None, iwid]
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
952 else:
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
953 return [self._outstr(name), iwid]
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
954
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1269
diff changeset
955 def xmlrpc_mergeDiff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name, normalised_name):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
956 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
957 Merges a diff sent by the remote machine and returns the number of the new revision.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
958 Additionally, this method tags the new revision.
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
959
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
960 @param pagename: The pagename that is currently dealt with.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
961 @param diff: The diff that can be applied to the version specified by delta_remote_rev.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
962 If it is None, the page is deleted.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
963 @param local_rev: The revno of the page on the other wiki system, used for the tag.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
964 @param delta_remote_rev: The revno that the diff is taken against.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
965 @param last_remote_rev: The last revno of the page `pagename` that is known by the other wiki site.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
966 @param interwiki_name: Used to build the interwiki tag.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
967 @param normalised_name: The normalised pagename that is common to both wikis.
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
968
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
969 @return: Returns the current revision number after the merge was done. Or one of the following errors:
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
970 * "SUCCESS" - the page could be merged and tagged successfully.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
971 * "NOT_EXIST" - item does not exist and there was not any content supplied.
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
972 * "LASTREV_INVALID" - the page was changed and the revision got invalid
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
973 * "INTERNAL_ERROR" - there was an internal error
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
974 * "NOT_ALLOWED" - you are not allowed to do the merge operation on the page
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
975 """
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
976 from MoinMoin.util.bdiff import decompress, patch
1269
151da160dcea Moved an import in the XMLRPC code.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
977 from MoinMoin.wikisync import TagStore, BOTH
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1315
diff changeset
978 from MoinMoin.packages import unpackLine
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
979 LASTREV_INVALID = xmlrpclib.Fault("LASTREV_INVALID", "The page was changed")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
980
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
981 pagename = self._instr(pagename)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
982
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1315
diff changeset
983 comment = u"Remote Merge - %r" % unpackLine(interwiki_name)[-1]
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
984
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
985 # User may read page?
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
986 if not self.request.user.may.read(pagename) or not self.request.user.may.write(pagename):
1385
8bf6e48c6236 Added rollback and exception logging to SyncPages.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1351
diff changeset
987 return xmlrpclib.Fault("NOT_ALLOWED", "You are not allowed to write to this page.")
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
988
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
989 # XXX add locking here!
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
990
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
991 # current version of the page
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
992 currentpage = PageEditor(self.request, pagename, do_editor_backup=0)
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
993
1325
c48e57b1460a Allow passing None for some rev parameters of mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
994 if last_remote_rev is not None and currentpage.get_real_rev() != last_remote_rev:
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
995 return LASTREV_INVALID
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
996
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
997 if not currentpage.exists() and diff is None:
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
998 return xmlrpclib.Fault("NOT_EXIST", "The page does not exist and no diff was supplied.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
999
1343
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
1000 if diff is None: # delete the page
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
1001 try:
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
1002 currentpage.deletePage(comment)
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
1003 except PageEditor.AccessDenied, (msg, ):
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
1004 return xmlrpclib.Fault("NOT_ALLOWED", msg)
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
1005 return currentpage.get_real_rev()
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
1006
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
1007 # base revision used for the diff
1325
c48e57b1460a Allow passing None for some rev parameters of mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
1008 basepage = Page(self.request, pagename, rev=(delta_remote_rev or 0))
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1009
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
1010 # generate the new page revision by applying the diff
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
1011 newcontents = patch(basepage.get_raw_body_str(), decompress(str(diff)))
1260
5d555ec6b40a Fixed a bug that was hard to track down in SyncPages (some hours spent :-/).
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1257
diff changeset
1012 #print "Diff against %r" % basepage.get_raw_body_str()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1013
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
1014 # write page
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
1015 try:
1325
c48e57b1460a Allow passing None for some rev parameters of mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
1016 currentpage.saveText(newcontents.decode("utf-8"), last_remote_rev or 0, comment=comment)
1257
5b015ced5609 Fixed a corner case where both wiki's pages are equal.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1256
diff changeset
1017 except PageEditor.Unchanged: # could happen in case of both wiki's pages being equal
5b015ced5609 Fixed a corner case where both wiki's pages are equal.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1256
diff changeset
1018 pass
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
1019 except PageEditor.EditConflict:
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
1020 return LASTREV_INVALID
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1021
1024
608fbab8b6c3 Fixed typos.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1020
diff changeset
1022 current_rev = currentpage.get_real_rev()
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
1023
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
1024 tags = TagStore(currentpage)
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1269
diff changeset
1025 tags.add(remote_wiki=interwiki_name, remote_rev=local_rev, current_rev=current_rev, direction=BOTH, normalised_name=normalised_name)
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
1026
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
1027 # XXX unlock page
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
1028
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
1029 return current_rev
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1030
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1031
758
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
1032 # XXX BEGIN WARNING XXX
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
1033 # All xmlrpc_*Attachment* functions have to be considered as UNSTABLE API -
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
1034 # they are neither standard nor are they what we need when we have switched
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
1035 # attachments (1.5 style) to mimetype items (hopefully in 1.6).
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
1036 # They will be partly removed, esp. the semantics of the function "listAttachments"
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
1037 # cannot be sensibly defined for items.
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
1038 # If the first beta or more stable release of 1.6 will have new item semantics,
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
1039 # we will remove the functions before it is released.
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1040 def xmlrpc_listAttachments(self, pagename):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1041 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1042 Get list of attachment names for page <pagename>.
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
1043 Deprecated.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
1044
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1045 @param pagename: pagename (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1046 @rtype: list
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1047 @return: a list of utf-8 attachment names
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1048 """
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1049 pagename = self._instr(pagename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1050 # User may read page?
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1051 if not self.request.user.may.read(pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1052 return self.notAllowedFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1053
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1054 result = AttachFile._get_files(self.request, pagename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1055 return result
756
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
1056
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1057 def xmlrpc_getAttachment(self, pagename, attachname):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1058 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1059 Get contents of attachment <attachname> of page <pagename>
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
1060
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1061 @param pagename: pagename (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1062 @param attachname: attachment name (utf-8)
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1063 @rtype: base64
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1064 @return: base64 data
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1065 """
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1066 pagename = self._instr(pagename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1067 # User may read page?
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1068 if not self.request.user.may.read(pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1069 return self.notAllowedFault()
756
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
1070
5362
8fc12793ba3e xmlrpc: process attachname in get and put Attachment similiar
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5345
diff changeset
1071 attachname = wikiutil.taintfilename(self._instr(attachname))
8fc12793ba3e xmlrpc: process attachname in get and put Attachment similiar
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5345
diff changeset
1072 filename = AttachFile.getFilename(self.request, pagename, attachname)
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1073 if not os.path.isfile(filename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1074 return self.noSuchPageFault()
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1075 return self._outlob(open(filename, 'rb').read())
756
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
1076
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1077 def xmlrpc_putAttachment(self, pagename, attachname, data):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1078 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1079 Store <data> as content of attachment <attachname> of page <pagename>.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
1080
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1081 @param pagename: pagename (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1082 @param attachname: attachment name (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1083 @param data: file data (base64)
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1084 @rtype: bool
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1085 @return: True if attachment was successfully stored
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1086 """
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1087 pagename = self._instr(pagename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1088 # User may read page?
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1089 if not self.request.user.may.read(pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1090 return self.notAllowedFault()
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1091
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1092 # also check ACLs
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1093 if not self.request.user.may.write(pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1094 return xmlrpclib.Fault(1, "You are not allowed to edit this page")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1095
5362
8fc12793ba3e xmlrpc: process attachname in get and put Attachment similiar
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5345
diff changeset
1096 attachname = wikiutil.taintfilename(self._instr(attachname))
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1097 filename = AttachFile.getFilename(self.request, pagename, attachname)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1098 if os.path.exists(filename) and not os.path.isfile(filename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1099 return self.noSuchPageFault()
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1100 open(filename, 'wb+').write(data.data)
5345
d5d4665013b2 xmlrpc.xmlrpc_putAttachment: fixed bug of too verbose log message (MoinMoinBugs/xmrpc_put_attachment_TooVerbose)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3873
diff changeset
1101 AttachFile._addLogEntry(self.request, 'ATTNEW', pagename, attachname)
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
1102 return xmlrpclib.Boolean(1)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1103
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1104 def xmlrpc_deleteAttachment(self, pagename, attachname):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1105 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1106 Deletes attachment <attachname> of page <pagename>.
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1107
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1108 @param pagename: pagename (utf-8)
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1109 @param attachname: attachment name (utf-8)
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1110 @rtype: bool
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1111 @return: True on success
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1112 """
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1113 pagename = self._instr(pagename)
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1114
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1115 if not self.request.user.may.delete(pagename):
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1116 return xmlrpclib.Fault(1, 'You are not allowed to delete attachments on this page.')
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1117
5364
0a2d5a05cd9b xmlrpc: process attachname in delete Attachment similiar to get and put
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5363
diff changeset
1118 attachname = wikiutil.taintfilename(self._instr(attachname))
5358
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1119 filename = AttachFile.getFilename(self.request, pagename, attachname)
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1120 AttachFile.remove_attachment(self.request, pagename, attachname)
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1121 return xmlrpclib.Boolean(1)
a5bd554abd87 xmlrpc: renamePage and deleteAttachment method added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5353
diff changeset
1122
2472
4e9370e2e8f1 Move xmlrpc_getBotTranslations() out of warning's scope.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2462
diff changeset
1123 # XXX END WARNING XXX
4e9370e2e8f1 Move xmlrpc_getBotTranslations() out of warning's scope.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2462
diff changeset
1124
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
1125 def xmlrpc_getBotTranslations(self):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1126 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1127 Return translations to be used by notification bot
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
1128
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
1129 @return: a dict (indexed by language) of dicts of translated strings (indexed by original ones)
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
1130 """
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
1131 from MoinMoin.i18n import bot_translations
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
1132 return bot_translations(self.request)
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
1133
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1134
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1135 class XmlRpc1(XmlRpcBase):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1136
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1137 def __init__(self, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1138 XmlRpcBase.__init__(self, request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1139 self.version = 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1140
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1141 def _instr(self, text):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1142 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1143 Convert string we get from xmlrpc into internal representation
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1144
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1145 @param text: quoted text (str or unicode object)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1146 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1147 @return: text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1148 """
101
2202f548cbb0 use own urllib wrapper, see wikiutil
Thomas Waldmann <tw@waldmann-edv.de>
parents: 53
diff changeset
1149 return wikiutil.url_unquote(text) # config.charset must be utf-8
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1150
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1151 def _outstr(self, text):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1152 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1153 Convert string from internal representation to xmlrpc
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1154
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1155 @param text: unicode or string in config.charset
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1156 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1157 @return: text encoded in utf-8 and quoted
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1158 """
101
2202f548cbb0 use own urllib wrapper, see wikiutil
Thomas Waldmann <tw@waldmann-edv.de>
parents: 53
diff changeset
1159 return wikiutil.url_quote(text) # config.charset must be utf-8
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1160
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1161
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1162 class XmlRpc2(XmlRpcBase):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1163
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1164 def __init__(self, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1165 XmlRpcBase.__init__(self, request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1166 self.version = 2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1167
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1168 def _instr(self, text):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1169 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1170 Convert string we get from xmlrpc into internal representation
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1171
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1172 @param text: unicode or utf-8 string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1173 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1174 @return: text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1175 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1176 if not isinstance(text, unicode):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1177 text = unicode(text, 'utf-8')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1178 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1179
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1180 def _outstr(self, text):
5359
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1181 """
92fdc2ecbad5 xmlrpc: cleaned up docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5358
diff changeset
1182 Convert string from internal representation to xmlrpc
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1183
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1184 @param text: unicode or string in config.charset
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1185 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1186 @return: text encoded in utf-8
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1187 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1188 if isinstance(text, unicode):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1189 text = text.encode('utf-8')
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1190 elif config.charset != 'utf-8':
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1191 text = unicode(text, config.charset).encode('utf-8')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1192 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1193
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1194
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1195 def xmlrpc(request):
4241
c27f6cb0892e Fixed: XMLRPC calls
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4210
diff changeset
1196 return XmlRpc1(request).process()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1197
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1198 def xmlrpc2(request):
4241
c27f6cb0892e Fixed: XMLRPC calls
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4210
diff changeset
1199 return XmlRpc2(request).process()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1200