annotate doc/examples/sat_pubsub.tac @ 299:07ad8d8fde77

item publisher is enforced
author Goffi <goffi@goffi.org>
date Wed, 25 Nov 2015 15:58:42 +0100
parents d55620ceafed
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
239
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
1 #!/usr/bin/python
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
2 #-*- coding: utf-8 -*-
194
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
3
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
4 """
239
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
5 Copyright (c) 2003-2011 Ralph Meijer
255
d55620ceafed copyright update
Goffi <goffi@goffi.org>
parents: 239
diff changeset
6 Copyright (c) 2012, 2013 Jérôme Poisson
239
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
7
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
8
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
9 This program is free software: you can redistribute it and/or modify
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
10 it under the terms of the GNU Affero General Public License as published by
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
11 the Free Software Foundation, either version 3 of the License, or
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
12 (at your option) any later version.
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
13
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
14 This program is distributed in the hope that it will be useful,
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
17 GNU Affero General Public License for more details.
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
18
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
19 You should have received a copy of the GNU Affero General Public License
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
21 --
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
22
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
23 This program is based on Idavoll (http://idavoll.ik.nu/),
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
24 originaly written by Ralph Meijer (http://ralphm.net/blog/)
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
25 It is sublicensed under AGPL v3 (or any later version) as allowed by the original
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
26 license.
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
27
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
28 --
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
29
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
30 Here is a copy of the original license:
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
31
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
32 Copyright (c) 2003-2011 Ralph Meijer
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
33
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
34 Permission is hereby granted, free of charge, to any person obtaining
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
35 a copy of this software and associated documentation files (the
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
36 "Software"), to deal in the Software without restriction, including
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
37 without limitation the rights to use, copy, modify, merge, publish,
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
38 distribute, sublicense, and/or sell copies of the Software, and to
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
39 permit persons to whom the Software is furnished to do so, subject to
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
40 the following conditions:
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
41
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
42 The above copyright notice and this permission notice shall be
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
43 included in all copies or substantial portions of the Software.
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
44
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
45 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
46 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
47 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
48 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
49 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
50 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
51 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
52
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
53 """
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
54
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
55 """
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
56 Example TAC for Salut à Toi Pubsub.
194
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
57 """
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
58
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
59 from twisted.application import service
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
60 from twisted.words.protocols.jabber.jid import JID
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
61
234
51af2ed8bd50 replaced idavoll imports by sat_pubsub imports
Goffi <goffi@goffi.org>
parents: 194
diff changeset
62 from sat_pubsub import tap
194
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
63
239
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
64 application = service.Application(u"SàT Pubsub")
194
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
65
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
66 config = {
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
67 'jid': JID('pubsub.example.org'),
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
68 'secret': 'secret',
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
69 'rhost': '127.0.0.1',
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
70 'rport': 5347,
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
71 'backend': 'memory',
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
72 'verbose': True,
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
73 'hide-nodes': False,
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
74 }
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
75
239
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
76 satPubsubService = tap.makeService(config)
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
77 satPubsubService.setServiceParent(application)
194
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
78
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
79 # Set the maximum delay until trying to reconnect.
239
2b50e4664d74 fixed setup.py and twistd plugin file
Goffi <goffi@goffi.org>
parents: 234
diff changeset
80 componentService = satPubsubService.getServiceNamed('component')
194
5974e718f395 Check in missing file, also part of Idavoll 0.7.3.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
81 componentService.factory.maxdelay = 300