annotate jabberbot/commands.py @ 5816:b661a89ef0be

xmlrpc: new methods xmlrpc_getProcessingInstruction and xmlrpc_getProcessingInstructionVersion
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 25 Dec 2011 23:56:09 +0100
parents 9a3e85b44c25
children
rev   line source
2099
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
2 """
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
3 MoinMoin - inter-thread communication commands
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
4
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
5 This file defines command objects used by notification
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
6 bot's threads to communicate among each other.
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
7
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
8 @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
10 """
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
11
2682
b0a44fc4d87d Towards more applications of data forms, with many bugs fixed along the way.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2677
diff changeset
12 from pyxmpp.jid import JID
b0a44fc4d87d Towards more applications of data forms, with many bugs fixed along the way.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2677
diff changeset
13
2099
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
14 # First, XML RPC -> XMPP commands
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
15 class NotificationCommand:
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
16 """Class representing a notification request"""
4542
9a3e85b44c25 Applying a patch from Noya to use an RFC compliant message type.
Karol 'grzywacz' Nowak <grywacz@gmail.com>
parents: 2694
diff changeset
17 def __init__(self, jids, notification, msg_type=u"normal", async=True):
2391
ddb4c626062d Big checkpoint commit. Details below:
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2354
diff changeset
18 """A constructor
2394
0f9b7b20fb9c Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2393
diff changeset
19
2391
ddb4c626062d Big checkpoint commit. Details below:
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2354
diff changeset
20 @param jids: a list of jids to sent this message to
2677
da70a91c03db Doc/argument type fixes.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2671
diff changeset
21 @param notification: dictionary with notification data
da70a91c03db Doc/argument type fixes.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2671
diff changeset
22 @param async: async notifications get queued if contact is DnD
2391
ddb4c626062d Big checkpoint commit. Details below:
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2354
diff changeset
23 @type jids: list
2394
0f9b7b20fb9c Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2393
diff changeset
24
2391
ddb4c626062d Big checkpoint commit. Details below:
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2354
diff changeset
25 """
2322
4b4868ae88f0 Replace prints with stdlib's logging features.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2319
diff changeset
26 if type(jids) != list:
4b4868ae88f0 Replace prints with stdlib's logging features.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2319
diff changeset
27 raise Exception("jids argument must be a list!")
2336
10be78f1fa97 Merge main.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2322 2286
diff changeset
28
2635
8ec6cc1a909f Change argument passing in notifications; some pylint and event.name fixes too
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2629
diff changeset
29 self.notification = notification
2319
10ec0e8d35e1 Make send_notification accept a list of JIDs, instead of one.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2127
diff changeset
30 self.jids = jids
2391
ddb4c626062d Big checkpoint commit. Details below:
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2354
diff changeset
31 self.async = async
2635
8ec6cc1a909f Change argument passing in notifications; some pylint and event.name fixes too
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2629
diff changeset
32 self.msg_type = msg_type
2629
5dac44252ca6 Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2626
diff changeset
33
2626
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
34 class NotificationCommandI18n(NotificationCommand):
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
35 """Notification request that should be translated by the XMPP bot"""
4542
9a3e85b44c25 Applying a patch from Noya to use an RFC compliant message type.
Karol 'grzywacz' Nowak <grywacz@gmail.com>
parents: 2694
diff changeset
36 def __init__(self, jids, notification, msg_type="normal", async=True):
2626
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
37 """A constructor
2629
5dac44252ca6 Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2626
diff changeset
38
2626
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
39 Params as in NotificationCommand.
2629
5dac44252ca6 Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2626
diff changeset
40
2626
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
41 """
2635
8ec6cc1a909f Change argument passing in notifications; some pylint and event.name fixes too
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2629
diff changeset
42 NotificationCommand.__init__(self, jids, notification, msg_type, async)
2629
5dac44252ca6 Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2626
diff changeset
43
2626
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
44 def translate(self, gettext_func):
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
45 """Translate the message using a provided gettext function
2629
5dac44252ca6 Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2626
diff changeset
46
2626
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
47 @param gettext_func: a unary gettext function
2638
6e84127a1860 Finally all known bugs fixed, OOB is used to send links with jabber. More...
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2635
diff changeset
48 @return: translated message and subject
6e84127a1860 Finally all known bugs fixed, OOB is used to send links with jabber. More...
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2635
diff changeset
49 @rtype: tuple
2626
a791fc964e09 Attempt to move i18n from xmlrpc to xmpp thread.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2501
diff changeset
50 """
2635
8ec6cc1a909f Change argument passing in notifications; some pylint and event.name fixes too
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2629
diff changeset
51 if self.notification.has_key('data'):
2638
6e84127a1860 Finally all known bugs fixed, OOB is used to send links with jabber. More...
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2635
diff changeset
52 msg = gettext_func(self.notification['text']) % self.notification['data']
2635
8ec6cc1a909f Change argument passing in notifications; some pylint and event.name fixes too
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2629
diff changeset
53 else:
2638
6e84127a1860 Finally all known bugs fixed, OOB is used to send links with jabber. More...
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2635
diff changeset
54 msg = gettext_func(self.notification['text'])
6e84127a1860 Finally all known bugs fixed, OOB is used to send links with jabber. More...
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2635
diff changeset
55
6e84127a1860 Finally all known bugs fixed, OOB is used to send links with jabber. More...
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2635
diff changeset
56 return (msg, gettext_func(self.notification.get('subject', '')))
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
57
2099
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
58 class AddJIDToRosterCommand:
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
59 """Class representing a request to add a new jid to roster"""
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
60 def __init__(self, jid):
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
61 self.jid = jid
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
62
2099
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
63 class RemoveJIDFromRosterCommand:
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
64 """Class representing a request to remove a jid from roster"""
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
65 def __init__(self, jid):
ab5e7026413a Move shared commands to a separate file, to make imports cleaner.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
66 self.jid = jid
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
67
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
68 # XMPP <-> XML RPC commands
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
69 # These commands are passed in both directions, with added data
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
70 # payload when they return to the XMPP code. Naming convention
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
71 # follows method names defined by the Wiki RPC Interface v2.
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
72
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
73 class BaseDataCommand(object):
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
74 """Base class for all commands used by the XMPP component.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
75
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
76 It has to support an optional data payload and store JID the
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
77 request has come from and provide a help string for its parameters.
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
78 """
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
79
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
80 # Description of what the command does
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
81 description = u""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
82
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
83 # Parameter list in a human-readable format
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
84 parameter_list = u""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
85
2694
6500951853e2 Make "get page info" work with data forms.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2682
diff changeset
86 def __init__(self, jid, presentation=u"text"):
2501
de573a7f49ce A small comment improvement.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
87 """A constructor
de573a7f49ce A small comment improvement.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
88
de573a7f49ce A small comment improvement.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
89 @param jid: Jabber ID to send the reply to
2694
6500951853e2 Make "get page info" work with data forms.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2682
diff changeset
90 @param presentation: how to display results; "text" or "dataforms"
2501
de573a7f49ce A small comment improvement.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
91 @type jid: unicode
2694
6500951853e2 Make "get page info" work with data forms.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2682
diff changeset
92 @type presentation: unicode
6500951853e2 Make "get page info" work with data forms.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2682
diff changeset
93
2501
de573a7f49ce A small comment improvement.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
94 """
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
95 self.jid = jid
2121
ae2134211ac1 XMPP -> wiki XML RPC, the beginning...
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2115
diff changeset
96 self.data = None
2694
6500951853e2 Make "get page info" work with data forms.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2682
diff changeset
97 self.presentation = presentation
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
98
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
99 class GetPage(BaseDataCommand):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
100
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
101 description = u"retrieve raw content of a named page"
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
102 parameter_list = u"pagename"
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
103
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
104 def __init__(self, jid, pagename):
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
105 BaseDataCommand.__init__(self, jid)
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
106 self.pagename = pagename
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
107
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
108 class GetPageHTML(BaseDataCommand):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
109
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
110 description = u"retrieve HTML-formatted content of a named page"
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
111 parameter_list = u"pagename"
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
112
2115
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
113 def __init__(self, jid, pagename):
260d0dbded44 Checkpoint commit, to record progress on implementation of user commands.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
114 BaseDataCommand.__init__(self, jid)
2125
9d5f4ba23a54 Add a GetPageList command. Some code duplication to be refactored later.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2121
diff changeset
115 self.pagename = pagename
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
116
2125
9d5f4ba23a54 Add a GetPageList command. Some code duplication to be refactored later.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2121
diff changeset
117 class GetPageList(BaseDataCommand):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
118
2125
9d5f4ba23a54 Add a GetPageList command. Some code duplication to be refactored later.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2121
diff changeset
119 description = u"get a list of accesible pages"
9d5f4ba23a54 Add a GetPageList command. Some code duplication to be refactored later.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2121
diff changeset
120 parameter_list = u""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
121
2125
9d5f4ba23a54 Add a GetPageList command. Some code duplication to be refactored later.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2121
diff changeset
122 def __init__(self, jid):
9d5f4ba23a54 Add a GetPageList command. Some code duplication to be refactored later.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2121
diff changeset
123 BaseDataCommand.__init__(self, jid)
2127
42232c6ac004 Remove code duplication in xmlrpcbot, initial support for getPageInfo()
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2125
diff changeset
124
42232c6ac004 Remove code duplication in xmlrpcbot, initial support for getPageInfo()
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2125
diff changeset
125 class GetPageInfo(BaseDataCommand):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
126
2127
42232c6ac004 Remove code duplication in xmlrpcbot, initial support for getPageInfo()
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2125
diff changeset
127 description = u"show detailed information about a page"
42232c6ac004 Remove code duplication in xmlrpcbot, initial support for getPageInfo()
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2125
diff changeset
128 parameter_list = u"pagename"
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2127
diff changeset
129
2694
6500951853e2 Make "get page info" work with data forms.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2682
diff changeset
130 def __init__(self, jid, pagename, presentation=u"text"):
6500951853e2 Make "get page info" work with data forms.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2682
diff changeset
131 BaseDataCommand.__init__(self, jid, presentation)
2127
42232c6ac004 Remove code duplication in xmlrpcbot, initial support for getPageInfo()
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2125
diff changeset
132 self.pagename = pagename
2394
0f9b7b20fb9c Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2393
diff changeset
133
2393
ae44e3266486 s/search/searchform/, add a Search command (does nothing)
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2391
diff changeset
134 class Search(BaseDataCommand):
2394
0f9b7b20fb9c Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2393
diff changeset
135
2393
ae44e3266486 s/search/searchform/, add a Search command (does nothing)
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2391
diff changeset
136 description = u"perform a wiki search"
ae44e3266486 s/search/searchform/, add a Search command (does nothing)
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2391
diff changeset
137 parameter_list = u"{title|text} term"
2394
0f9b7b20fb9c Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2393
diff changeset
138
2664
4d4a1a5c0c42 Data forms search now works. Display of results... almost (no idea why not atm).
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2650
diff changeset
139 def __init__(self, jid, search_type, *args, **kwargs):
2393
ae44e3266486 s/search/searchform/, add a Search command (does nothing)
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2391
diff changeset
140 BaseDataCommand.__init__(self, jid)
2677
da70a91c03db Doc/argument type fixes.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2671
diff changeset
141
da70a91c03db Doc/argument type fixes.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2671
diff changeset
142 if not JID(jid).resource:
da70a91c03db Doc/argument type fixes.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2671
diff changeset
143 raise ValueError("The jid argument must be a full jabber id!")
da70a91c03db Doc/argument type fixes.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2671
diff changeset
144
2650
2b4be3be9835 First implementation of search, will be changed later to optionally use oob.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2638
diff changeset
145 self.term = ' '.join(args)
2393
ae44e3266486 s/search/searchform/, add a Search command (does nothing)
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2391
diff changeset
146 self.search_type = search_type
2664
4d4a1a5c0c42 Data forms search now works. Display of results... almost (no idea why not atm).
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2650
diff changeset
147 self.presentation = kwargs.get('presentation', 'text') # "text" or "dataforms"
4d4a1a5c0c42 Data forms search now works. Display of results... almost (no idea why not atm).
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2650
diff changeset
148 self.case = kwargs.get('case', False)
2650
2b4be3be9835 First implementation of search, will be changed later to optionally use oob.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2638
diff changeset
149 self.mtime = None
2664
4d4a1a5c0c42 Data forms search now works. Display of results... almost (no idea why not atm).
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2650
diff changeset
150 self.regexp = kwargs.get('regexp', False)
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
151
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
152
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
153 class RevertPage(BaseDataCommand):
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
154
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
155 description = u"revert a page to previous revision"
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
156 parameter_list = u"page_name revision"
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
157
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
158 def __init__(self, jid, pagename, revision):
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
159 BaseDataCommand.__init__(self, jid)
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
160 self.pagename = pagename
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
161 self.revision = revision
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
162
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
163
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
164 class GetUserLanguage:
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
165 """Request user's language information from wiki"""
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
166
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
167 def __init__(self, jid):
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
168 """
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
169 @param jid: user's (bare) Jabber ID
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
170 """
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
171 self.jid = jid
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2394
diff changeset
172 self.language = None
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2664
diff changeset
173