annotate MoinMoin/xmlrpc/__init__.py @ 3175:2a3a6cb34e45

pylint findings: fix some harmless stuff
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 03 Mar 2008 02:02:55 +0100
parents ed9b1e5cf0e1
children a739558ca3dc
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
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
20 @copyright: 2003-2007 MoinMoin:ThomasWaldmann,
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1804
diff changeset
21 2004-2006 MoinMoin:AlexanderSchremmer
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 @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
23 """
637
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
24 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
25
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
26 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
27
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
28 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
29
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30 from MoinMoin import config, user, wikiutil
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 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
32 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
33 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
34 from MoinMoin.action import AttachFile
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
35 from MoinMoin import caching
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
36 from MoinMoin import session
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 _debug = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
39
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 class XmlRpcAuthTokenIDHandler(session.SessionIDHandler):
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
42 def __init__(self, token=None):
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
43 session.SessionIDHandler.__init__(self)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
44 self.token = token
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
45
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
46 def get(self, request):
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
47 return self.token
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
48
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
49 def set(self, request, session_id, expires):
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
50 self.token = session_id
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
51
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
52
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53 class XmlRpcBase:
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
54 """ XMLRPC base class with common functionality of wiki xmlrpc v1 and v2 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55 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
56 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 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
58 @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
59 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 self.request = request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 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
62 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
63
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
64 #############################################################################
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
65 ### Helper functions
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
66 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
67
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68 def _instr(self, text):
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
69 """ Convert inbound string.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
70
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
71 @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
72 @rtype: unicode
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
73 @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
74 """
1072
c1f5ee67a02b use exception class instead of string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
75 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
76
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
77 def _outstr(self, text):
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
78 """ 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
79
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
80 @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
81 @rtype: str
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
82 @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
83 """
1072
c1f5ee67a02b use exception class instead of string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
84 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
85
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
86 def _inlob(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 """ 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
88
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
89 @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
90 @rtype: unicode
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 text = text.data #this is a already base64-decoded 8bit string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
94 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
95 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
96
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
97 def _outlob(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
98 """ 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
99
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
100 @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
101 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
102 @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
103 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
104 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
105 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
106 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
107 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
108 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
109 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
110
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
111 def _dump_exc(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
112 """ 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
113
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
114 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
115 @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
116 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117 import traceback
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
118
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
119 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
120 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
121 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
122 '\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
123 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
124
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
125 def process(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
126 """ xmlrpc v1 and v2 dispatcher """
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
127 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
128 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
129 # 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
130 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
131 else:
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 data = self.request.read()
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
133 params, method = xmlrpclib.loads(data)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
134
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
135 if _debug:
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
136 sys.stderr.write('- XMLRPC ' + '-' * 70 + '\n')
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
137 sys.stderr.write('%s(%s)\n\n' % (method, repr(params)))
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
138
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
139 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
140 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
141 # report exception back to server
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
142 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
143 else:
1160
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
144 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
145 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
146 else:
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
147 # 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
148 response = (response, )
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
149
1160
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
150 # serialize it
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
151 response = xmlrpclib.dumps(response, methodresponse=1)
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
152
1068
ecece5db5288 use emit_http_headers
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1053
diff changeset
153 self.request.emit_http_headers([
ecece5db5288 use emit_http_headers
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1053
diff changeset
154 "Content-Type: text/xml; charset=utf-8",
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
155 "Content-Length: %d" % len(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
156 ])
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 self.request.write(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
158
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
159 if _debug:
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
160 sys.stderr.write('- XMLRPC ' + '-' * 70 + '\n')
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
161 sys.stderr.write(response + '\n\n')
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
162
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
163 def dispatch(self, method, params):
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
164 """ call dispatcher - for method==xxx it either locates a method called
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
165 xmlrpc_xxx or loads a plugin from plugin/xmlrpc/xxx.py
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
166 """
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
167 method = method.replace(".", "_")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
168
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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 response = fn(*params)
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 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
184
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 # Common faults -----------------------------------------------------
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
186
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
187 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
188 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
189
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 def noSuchPageFault(self):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
191 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
192
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 #############################################################################
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 ### 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
195 #############################################################################
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
196
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 def xmlrpc_system_multicall(self, 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
198 """system.multicall([{'methodName': 'add', 'params': [2, 2]}, ...]) => [[4], ...]
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
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
200 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
201 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
202
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 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
204
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
205 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
206 """
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
207
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
208 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
209 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
210 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
211 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
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 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
214 # 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
215 # 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
216 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
217
2126
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
218 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
219 results.append([result])
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
220 else:
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
221 results.append(
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
222 {'faultCode': result.faultCode,
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
223 'faultString': result.faultString}
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
224 )
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
225 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
226 results.append(
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
227 {'faultCode': 1,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
228 '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
229 )
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
230
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
231 return results
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
232
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
233 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
234 ### Interface implementation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
235 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
236
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
237 def xmlrpc_getRPCVersionSupported(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
238 """ Returns version of the Wiki API.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
239
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
240 @rtype: int
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
241 @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
242 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
243 return self.version
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
244
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
245 def xmlrpc_getAllPages(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
246 """ Get all pages readable by current user
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
247
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
248 @rtype: list
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
249 @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
250 """
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
251
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
252 # the official WikiRPC interface is implemented by the extended method
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
253 # as well
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
254 return self.xmlrpc_getAllPagesEx()
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
255
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
256
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
257 def xmlrpc_getAllPagesEx(self, opts=None):
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
258 """ Get all pages readable by current user. Not an WikiRPC method.
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
259
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
260 @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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268 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
269 @rtype: list
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
270 @return: a list of all pages.
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
271 """
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
272 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
273 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
274 "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
275 "pagelist": None, "mark_deleted": False}
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
276 if opts is not None:
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
277 options.update(opts)
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
278
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
279 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
280 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
281 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
282 p_filter = lambda name: True
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
283
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
284 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
285 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
286
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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295 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
296 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
297
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
298 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
299 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
300 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
301
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
302 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
303 pages = []
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
304 for page in pagelist:
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
305 revno = page.get_real_rev()
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
306 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
307 revno = -revno
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
308 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
309 return pages
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
310 else:
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
311 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
312
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
313 def xmlrpc_getRecentChanges(self, date):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
314 """ 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
315
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
316 @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
317 @rtype: list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
318 @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
319 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
320 * name (string) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
321 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
322 * lastModified (date) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
323 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
324 * author (string) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
325 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
326 * version (int) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
327 Current version.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
328 """
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
329
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
330 return_items = []
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
331
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
332 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
333 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
334 # 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
335 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
336 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
337
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
338 # 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
339 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
340 break
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
341
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
342 # 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
343 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
344 continue
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
345
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
346 # 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
347 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
348
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
349 # 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
350 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
351 if log.userid:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
352 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
353 if userdata.name:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
354 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
355 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
356
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
357 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
358 'lastModified': lastModified_date,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
359 'author': author_str,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
360 '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
361 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
362
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
363 return return_items
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
364
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
365 def xmlrpc_getPageInfo(self, pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
366 """ Invoke xmlrpc_getPageInfoVersion with rev=None """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
367 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
368
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
369 def xmlrpc_getPageInfoVersion(self, pagename, rev):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
370 """ 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
371
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
372 @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
373 @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
374 @rtype: dict
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
375 @return: page information
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
376 * 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
377 * 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
378 * 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
379 * 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
380
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
381 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
382 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
383
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
384 # 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
385 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
386 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
387
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
388 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
389 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
390 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
391 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
392 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
393
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
394 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
395 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
396 return self.noSuchPageFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
397
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
398 # Get page info
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
399 last_edit = page.last_edit(self.request)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
400 mtime = wikiutil.version2timestamp(long(last_edit['timestamp'])) # must be long for py 2.2.x
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 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
402
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403 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
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 # 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
407 # 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
408 # 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
409 # 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
410 # 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
411 # 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
412 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
413 version = int(mtime)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
414 #######################################################################
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
415
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
416 return {
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
417 '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
418 'lastModified': xmlrpclib.DateTime(gmtuple),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
419 'author': self._outstr(last_edit['editor']),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
420 'version': version,
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
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
423 def xmlrpc_getPage(self, pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
424 """ Invoke xmlrpc_getPageVersion with rev=None """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
425 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
426
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
427 def xmlrpc_getPageVersion(self, pagename, rev):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
428 """ 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
429
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
430 @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
431 @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
432 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
433 @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
434 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
435 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
436
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
437 # 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
438 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
439 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
440
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
441 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
442 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
443 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
444 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
445
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
446 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
447 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
448 return self.noSuchPageFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
449
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
450 # 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
451 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
452 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
453 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
454 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
455
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
456 def xmlrpc_getPageHTML(self, pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
457 """ Invoke xmlrpc_getPageHTMLVersion with rev=None """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
458 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
459
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
460 def xmlrpc_getPageHTMLVersion(self, pagename, rev):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
461 """ 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
462
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
463 @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
464 @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
465 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
466 @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
467 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
468 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
469
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
470 # 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
471 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
472 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
473
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
474 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
475 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
476 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
477 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
478
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
479 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
480 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
481 return self.noSuchPageFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
482
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
483 # 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
484 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
485
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
486 # Return rendered page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
487 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
488 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
489 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
490 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
491
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
492 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
493 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
494 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
495 @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
496 @rtype: list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
497 @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
498 * 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
499 * 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
500 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
501 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
502 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
503
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
504 # 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
505 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
506 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
507
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
508 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
509
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
510 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
511 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
512 return self.noSuchPageFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
513
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
514 links_out = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
515 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
516 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
517 return links_out
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
518
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
519 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
520 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
521 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
522 @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
523 @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
524 @rtype: bool
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
525 @return: true on success
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
526 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
527
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
528 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
529
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
530 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
531 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
532
2916
06547d7df727 fix putPage comment
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2915
diff changeset
533 # check ACLs
0
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.write(pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
535 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
536
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
537 page = PageEditor(self.request, pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
538 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
539 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
540 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
541 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
542 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
543 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
544 except page.SaveError, msg:
2915
05d90815b0f9 xmlrpc: fault on save errors
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2914
diff changeset
545 if _debug:
05d90815b0f9 xmlrpc: fault on save errors
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2914
diff changeset
546 sys.stderr.write("Msg: %s\n" % msg)
05d90815b0f9 xmlrpc: fault on save errors
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2914
diff changeset
547 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
548
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
549 # Update pagelinks cache
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
550 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
551
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
552 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
553
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
554 def xmlrpc_revertPage(self, pagename, revision):
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
555 """Revert a page to previous revision
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
556
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
557 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
558
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
559 @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
560 @param revision: revision to revert to
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
561 @rtype bool
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
562 @return true on success
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
563
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
564 """
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
565 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
566 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
567
2698
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
568 rev = int(self._instr(revision))
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
569 editor = PageEditor(self.request, pagename)
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
570
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
571 try:
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
572 editor.revertPage(rev)
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
573 except PageEditor.SaveError, error:
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
574 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
575
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
576 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
577
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
578 def xmlrpc_searchPages(self, query_string):
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
579 """ Searches pages for query_string.
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
580 Returns a list of tuples (foundpagename, context)
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
581 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
582 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
583 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
584 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
585 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
586 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
587 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
588 for hit in results.hits]
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
589
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
590 def xmlrpc_searchPagesEx(self, query_string, search_type, length, case, mtime, 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
591 """ 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
592
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
593 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
594
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
595 @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
596 @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
597 @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
598 @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
599 @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
600 @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
601 @return: (page name, context preview, page url)
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
602
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
603 """
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
604 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
605 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
606
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
607 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
608 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
609 kwargs["titlesearch"] = True
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
610
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
611 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
612 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
613 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
614
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
615 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
616 self._outstr(results.formatContext(hit, length, 1)),
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
617 self.request.getQualifiedURL(hit.page.url(self.request, {}, relative=False)))
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
618 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
619
782
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
620 def xmlrpc_getMoinVersion(self):
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
621 """ Returns a tuple of the MoinMoin version:
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
622 (project, release, revision)
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
623 """
782
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
624 from MoinMoin import version
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
625 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
626
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
627
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
628 # 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
629
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
630 def xmlrpc_getUserProfile(self):
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
631 """ Return the user profile data for the current 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
632 Use this in a single multicall after applyAuthToken.
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
633 If we have a valid user, returns a dict of items from user profile.
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
634 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
635 """
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
636 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
637 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
638 userdata = {}
1951
a05a3b447db5 interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
639 else:
a05a3b447db5 interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
640 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
641 return userdata
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
642
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
643 def xmlrpc_getUserLanguageByJID(self, jid):
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
644 """ Returns user's language given his/her Jabber ID
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
645
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
646 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
647 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
648 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
649
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
650 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
651 """
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
652 retval = "en"
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
653 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
654 if u:
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
655 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
656
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
657 return retval
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
658
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
659 # 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
660
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
661 def xmlrpc_getAuthToken(self, username, password, *args):
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
662 """ Returns a token which can be used for authentication
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
663 in other XMLRPC calls. If the token is empty, the username
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
664 or the password were wrong.
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
665 """
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
666 id_handler = XmlRpcAuthTokenIDHandler()
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
667
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
668 u = self.request.cfg.session_handler.start(self.request, id_handler)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
669 u = self.request.handle_auth(u, username=username,
2009
1b14cc05a54a refactor authentication and split out session handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 1977
diff changeset
670 password=password, login=True)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
671
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
672 self.request.cfg.session_handler.after_auth(self.request, id_handler, u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
673
2009
1b14cc05a54a refactor authentication and split out session handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 1977
diff changeset
674 if u and u.valid:
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
675 return id_handler.token
955
05b7c435a3d6 Implemented token functions that use the normal moin id
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 954
diff changeset
676 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
677 return ""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
678
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
679 def xmlrpc_getJabberAuthToken(self, jid, secret):
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
680 """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
681
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
682 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
683 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
684 and Jabber bot.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
685
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
686 @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
687 """
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
688 if self.cfg.secret != secret:
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
689 return ""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
690
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
691 u = self.request.handle_jid_auth(jid)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
692
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
693 if u and u.valid:
2499
b5a711a9ec09 Fix generation of auth tokens in xmlrpc code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2472
diff changeset
694 return self._generate_auth_token(u)
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
695 else:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
696 return ""
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
697
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
698 def xmlrpc_applyAuthToken(self, auth_token):
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
699 """ Applies the auth token and thereby authenticates the user. """
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
700 id_handler = XmlRpcAuthTokenIDHandler(auth_token)
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
701
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
702 u = self.request.cfg.session_handler.start(self.request, id_handler)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
703 u = self.request.handle_auth(u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
704 self.request.cfg.session_handler.after_auth(self.request, id_handler, u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
705 if u and u.valid:
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
706 return "SUCCESS"
955
05b7c435a3d6 Implemented token functions that use the normal moin id
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 954
diff changeset
707 else:
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
708 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
709
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
710
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
711 def xmlrpc_deleteAuthToken(self, auth_token):
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
712 """ Delete the given auth token. """
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
713 id_handler = XmlRpcAuthTokenIDHandler(auth_token)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
714
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
715 u = self.request.cfg.session_handler.start(self.request, id_handler)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
716 u = self.request.handle_auth(u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
717 self.request.cfg.session_handler.after_auth(self.request, id_handler, u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
718
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
719 self.request.session.delete()
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
720
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
721 return "SUCCESS"
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
722
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
723
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
724 # methods for wiki synchronization
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
725
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
726 def xmlrpc_getDiff(self, pagename, from_rev, to_rev, n_name=None):
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
727 """ Gets the binary difference between two page revisions.
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
728
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
729 @param pagename: unicode string qualifying the page name
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
730
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
731 @param fromRev: integer specifying the source revision. May be None to
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
732 refer to a virtual empty revision which leads to a diff
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
733 containing the whole page.
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
734
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
735 @param toRev: integer specifying the target revision. May be None to
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
736 refer to the current revision. If the current revision is the same
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
737 as fromRev, there will be a special error condition "ALREADY_CURRENT"
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
738
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
739 @param n_name: do a tag check verifying that n_name was the normalised
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
740 name of the last tag
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
741
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
742 If both fromRev and toRev are None, this function acts similar to getPage, i.e. it will diff("",currentRev).
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
743
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
744 @return Returns a dict:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
745 * status (not a field, implicit, returned as Fault if not SUCCESS):
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
746 * "SUCCESS" - if the diff could be retrieved successfully
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
747 * "NOT_EXIST" - item does not exist
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
748 * "FROMREV_INVALID" - the source revision is invalid
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
749 * "TOREV_INVALID" - the target revision is invalid
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
750 * "INTERNAL_ERROR" - there was an internal error
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
751 * "INVALID_TAG" - the last tag does not match the supplied normalised name
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
752 * "ALREADY_CURRENT" - this not merely an error condition. It rather means that
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
753 there is no new revision to diff against which is a good thing while
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
754 synchronisation.
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
755 * current: the revision number of the current revision (not the one which was diff'ed against)
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
756 * diff: Binary object that transports a zlib-compressed binary diff (see bdiff.py, taken from Mercurial)
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
757 * conflict: if there is a conflict on the page currently
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
758
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
759 """
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
760 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
761 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
762
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
763 pagename = self._instr(pagename)
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
764 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
765 n_name = self._instr(n_name)
787
9d74a2f53323 Merge with main.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 786 758
diff changeset
766
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
767 # User may read page?
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
768 if not self.request.user.may.read(pagename):
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
769 return self.notAllowedFault()
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
770
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
771 def allowed_rev_type(data):
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
772 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
773 return True
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
774 return isinstance(data, int) and data > 0
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
775
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
776 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
777 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
778
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
779 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
780 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
781
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
782 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
783 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
784 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
785
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
786 revisions = currentpage.getRevList()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
787
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
788 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
789 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
790 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
791 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
792
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
793 # 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
794 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
795 oldcontents = lambda: ""
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
796 else:
1074
40b708ecc332 Fixed minor bug in XMLRPC code.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
797 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
798 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
799
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
800 if to_rev is None:
1250
97e9866e82c7 Fixed minor bug in getDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1161
diff changeset
801 newpage = currentpage
1256
f3c8f750c1fe Another minor unicode bug in getDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1255
diff changeset
802 newcontents = lambda: currentpage.get_raw_body_str()
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
803 else:
1074
40b708ecc332 Fixed minor bug in XMLRPC code.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
804 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
805 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
806
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
807 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
808 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
809
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
810 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
811 tags = TagStore(newpage)
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
812 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
813 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
814 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
815
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
816 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
817 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
818 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
819
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
820 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
821
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
822 def xmlrpc_interwikiName(self):
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
823 """ Returns the interwiki name and the IWID of the current wiki. """
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
824 name = self.request.cfg.interwikiname
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
825 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
826 if name is None:
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
827 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
828 else:
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
829 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
830
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
831 def xmlrpc_mergeDiff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name, normalised_name):
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
832 """ Merges a diff sent by the remote machine and returns the number of the new revision.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
833 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
834
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
835 @param pagename: The pagename that is currently dealt with.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
836 @param diff: The diff that can be applied to the version specified by delta_remote_rev.
1343
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
837 If it is None, the page is deleted.
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
838 @param local_rev: The revno of the page on the other wiki system, used for the tag.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
839 @param delta_remote_rev: The revno that the diff is taken against.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
840 @param last_remote_rev: The last revno of the page `pagename` that is known by the other wiki site.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
841 @param interwiki_name: Used to build the interwiki tag.
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
842 @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
843
1343
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
844 @return Returns the current revision number after the merge was done. Or one of the following errors:
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
845 * "SUCCESS" - the page could be merged and tagged successfully.
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
846 * "NOT_EXIST" - item does not exist and there was not any content supplied.
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
847 * "LASTREV_INVALID" - the page was changed and the revision got invalid
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
848 * "INTERNAL_ERROR" - there was an internal error
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
849 * "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
850 """
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
851 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
852 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
853 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
854 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
855
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
856 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
857
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
858 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
859
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
860 # 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
861 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
862 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
863
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
864 # 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
865
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
866 # 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
867 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
868
1325
c48e57b1460a Allow passing None for some rev parameters of mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
869 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
870 return LASTREV_INVALID
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
871
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
872 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
873 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
874
1343
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
875 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
876 try:
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
877 currentpage.deletePage(comment)
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
878 except PageEditor.AccessDenied, (msg, ):
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
879 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
880 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
881
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
882 # 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
883 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
884
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
885 # 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
886 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
887 #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
888
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
889 # write page
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
890 try:
1325
c48e57b1460a Allow passing None for some rev parameters of mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
891 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
892 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
893 pass
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
894 except PageEditor.EditConflict:
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
895 return LASTREV_INVALID
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
896
1024
608fbab8b6c3 Fixed typos.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1020
diff changeset
897 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
898
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
899 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
900 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
901
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
902 # XXX unlock page
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
903
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
904 return current_rev
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
905
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
906
758
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
907 # XXX BEGIN WARNING XXX
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
908 # 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
909 # 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
910 # 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
911 # 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
912 # 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
913 # 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
914 # 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
915 def xmlrpc_listAttachments(self, 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
916 """ Get all attachments associated with pagename
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
917 Deprecated.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
918
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
919 @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
920 @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
921 @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
922 """
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
923 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
924 # 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
925 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
926 return self.notAllowedFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
927
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
928 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
929 return result
756
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
930
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
931 def xmlrpc_getAttachment(self, 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
932 """ Get attachname associated with pagename
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
933
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
934 @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
935 @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
936 @rtype base64
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
937 @return base64 data
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
938 """
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
939 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
940 # 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
941 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
942 return self.notAllowedFault()
756
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
943
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
944 filename = wikiutil.taintfilename(self._instr(attachname))
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
945 filename = AttachFile.getFilename(self.request, pagename, filename)
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
946 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
947 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
948 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
949
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
950 def xmlrpc_putAttachment(self, pagename, attachname, data):
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
951 """ Set attachname associated with pagename to data
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
952
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
953 @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
954 @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
955 @param data: file data (base64)
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
956 @rtype boolean
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
957 @return True if attachment was set
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
958 """
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
959 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
960 # 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
961 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
962 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
963
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
964 # 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
965 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
966 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
967
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
968 attachname = wikiutil.taintfilename(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
969 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
970 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
971 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
972 open(filename, 'wb+').write(data.data)
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
973 AttachFile._addLogEntry(self.request, 'ATTNEW', pagename, 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
974 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
975
2472
4e9370e2e8f1 Move xmlrpc_getBotTranslations() out of warning's scope.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2462
diff changeset
976 # 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
977
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
978
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
979 def xmlrpc_getBotTranslations(self):
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
980 """ Return translations to be used by notification bot
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
981
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
982 @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
983 """
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
984 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
985 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
986
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
987
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
988 class XmlRpc1(XmlRpcBase):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
989
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
990 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
991 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
992 self.version = 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
993
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
994 def _instr(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
995 """ Convert string we get from xmlrpc into internal representation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
996
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
997 @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
998 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
999 @return: text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1000 """
101
2202f548cbb0 use own urllib wrapper, see wikiutil
Thomas Waldmann <tw@waldmann-edv.de>
parents: 53
diff changeset
1001 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
1002
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1003 def _outstr(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1004 """ Convert string from internal representation to xmlrpc
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1005
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1006 @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
1007 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1008 @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
1009 """
101
2202f548cbb0 use own urllib wrapper, see wikiutil
Thomas Waldmann <tw@waldmann-edv.de>
parents: 53
diff changeset
1010 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
1011
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1012
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1013 class XmlRpc2(XmlRpcBase):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1014
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1015 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
1016 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
1017 self.version = 2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1018
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1019 def _instr(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1020 """ Convert string we get from xmlrpc into internal representation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1021
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1022 @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
1023 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1024 @return: text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1025 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1026 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
1027 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
1028 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1029
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1030 def _outstr(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1031 """ Convert string from internal representation to xmlrpc
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1032
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1033 @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
1034 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1035 @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
1036 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1037 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
1038 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
1039 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
1040 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
1041 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1042
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1043
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1044 def xmlrpc(request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1045 XmlRpc1(request).process()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1046
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1047
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1048 def xmlrpc2(request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1049 XmlRpc2(request).process()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1050