This file is indexed.

/usr/share/doc/phatch/html/other.pubsub.html is in phatch-doc 0.2.7.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>pubsub &mdash; Phatch v0.2 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Phatch v0.2 documentation" href="index.html" />
    <link rel="up" title="other" href="other.html" />
    <link rel="next" title="pyWx" href="other.pyWx.html" />
    <link rel="prev" title="TiffImagePlugin" href="other.pil_1_1_6.TiffImagePlugin.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="other.pyWx.html" title="pyWx"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="other.pil_1_1_6.TiffImagePlugin.html" title="TiffImagePlugin"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Phatch v0.2 documentation</a> &raquo;</li>
          <li><a href="other.html" accesskey="U">other</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-other.pubsub">
<span id="pubsub"></span><h1>pubsub<a class="headerlink" href="#module-other.pubsub" title="Permalink to this headline"></a></h1>
<p>This module provides a publish-subscribe component that allows
listeners to subcribe to messages of a given topic. Contrary to the
original wxPython.lib.pubsub module (which it is based on), it uses 
weak referencing to the subscribers so the lifetime of subscribers 
is not affected by Publisher. Also, callable objects can be used in 
addition to functions and bound methods. See Publisher class docs for 
more details.</p>
<p>Thanks to Robb Shecter and Robin Dunn for having provided 
the basis for this module (which now shares most of the concepts but
very little design or implementation with the original 
wxPython.lib.pubsub).</p>
<p>The publisher is a singleton instance of the PublisherClass class. You 
access the instance via the Publisher object available from the module:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">wx.lib.pubsub</span> <span class="kn">import</span> <span class="n">Publisher</span>
<span class="n">Publisher</span><span class="p">()</span><span class="o">.</span><span class="n">subscribe</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="n">Publisher</span><span class="p">()</span><span class="o">.</span><span class="n">sendMessage</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="o">...</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Author:</th><td class="field-body">Oliver Schoenborn</td>
</tr>
<tr class="field"><th class="field-name">Since:</th><td class="field-body">Apr 2004</td>
</tr>
<tr class="field"><th class="field-name">Version:</th><td class="field-body">$Id: pubsub.py,v 1.8 2006/06/11 00:12:59 RD Exp $</td>
</tr>
<tr class="field"><th class="field-name">Copyright:</th><td class="field-body">(c) 2004 Oliver Schoenborn</td>
</tr>
<tr class="field"><th class="field-name">License:</th><td class="field-body">wxWidgets</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="other.pubsub.Message">
<em class="property">class </em><tt class="descclassname">other.pubsub.</tt><tt class="descname">Message</tt><big>(</big><em>topic</em>, <em>data</em><big>)</big><a class="headerlink" href="#other.pubsub.Message" title="Permalink to this definition"></a></dt>
<dd><p>A simple container object for the two components of a message: the 
topic and the user data. An instance of Message is given to your 
listener when called by Publisher().sendMessage(topic) (if your
listener callback was registered for that topic).</p>
</dd></dl>

<dl class="class">
<dt id="other.pubsub.PublisherClass">
<em class="property">class </em><tt class="descclassname">other.pubsub.</tt><tt class="descname">PublisherClass</tt><big>(</big><em>singletonKey</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass" title="Permalink to this definition"></a></dt>
<dd><p>The publish/subscribe manager.  It keeps track of which listeners
are interested in which topics (see subscribe()), and sends a
Message for a given topic to listeners that have subscribed to
that topic, with optional user data (see sendMessage()).</p>
<p>The three important concepts for Publisher are:</p>
<ul>
<li><p class="first">listener: a function, bound method or
callable object that can be called with one parameter
(not counting &#8216;self&#8217; in the case of methods). The parameter
will be a reference to a Message object. E.g., these listeners
are ok:</p>
<div class="highlight-python"><pre>class Foo:
    def __call__(self, a, b=1): pass # can be called with only one arg
    def meth(self,  a):         pass # takes only one arg
    def meth2(self, a=2, b=''): pass # can be called with one arg

def func(a, b=''): pass

Foo foo
Publisher().subscribe(foo)           # functor
Publisher().subscribe(foo.meth)      # bound method
Publisher().subscribe(foo.meth2)     # bound method
Publisher().subscribe(func)          # function</pre>
</div>
<p>The three types of callables all have arguments that allow a call 
with only one argument. In every case, the parameter &#8216;a&#8217; will contain
the message.</p>
</li>
<li><p class="first">topic: a single word, a tuple of words, or a string containing a
set of words separated by dots, for example: &#8216;sports.baseball&#8217;.
A tuple or a dotted notation string denotes a hierarchy of
topics from most general to least. For example, a listener of
this topic:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">(</span><span class="s">&#39;sports&#39;</span><span class="p">,</span><span class="s">&#39;baseball&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>would receive messages for these topics:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">(</span><span class="s">&#39;sports&#39;</span><span class="p">,</span> <span class="s">&#39;baseball&#39;</span><span class="p">)</span>                 <span class="c"># because same</span>
<span class="p">(</span><span class="s">&#39;sports&#39;</span><span class="p">,</span> <span class="s">&#39;baseball&#39;</span><span class="p">,</span> <span class="s">&#39;highscores&#39;</span><span class="p">)</span>   <span class="c"># because more specific</span>
</pre></div>
</div>
<p>but not these:</p>
<div class="highlight-python"><pre> 'sports'      # because more general
('sports',)    # because more general
() or ('')     # because only for those listening to 'all' topics
('news')       # because different topic</pre>
</div>
</li>
<li><p class="first">message: this is an instance of Message, containing the topic for 
which the message was sent, and any data the sender specified.</p>
</li>
</ul>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Note :</th><td class="field-body">This class is visible to importers of pubsub only as a
Singleton. I.e., every time you execute &#8216;Publisher()&#8217;, it&#8217;s
actually the same instance of PublisherClass that is
returned. So to use, just do&#8217;Publisher().method()&#8217;.</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="other.pubsub.PublisherClass.getAssociatedTopics">
<tt class="descname">getAssociatedTopics</tt><big>(</big><em>listener</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.getAssociatedTopics" title="Permalink to this definition"></a></dt>
<dd><p>Return a list of topics the given listener is registered with. 
Returns [] if listener never subscribed.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Attention :</th><td class="field-body"><p class="first">when using the return of this method to compare to
expected list of topics, remember that topics that are
not in the form of a tuple appear as a one-tuple in
the return. E.g. if you have subscribed a listener to
&#8216;topic1&#8217; and (&#8216;topic2&#8217;,&#8217;subtopic2&#8217;), this method
returns:</p>
<p class="last">associatedTopics = [(&#8216;topic1&#8217;,), (&#8216;topic2&#8217;,&#8217;subtopic2&#8217;)]</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.getDeliveryCount">
<tt class="descname">getDeliveryCount</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.getDeliveryCount" title="Permalink to this definition"></a></dt>
<dd><p>How many listeners have received a message since beginning of run</p>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.getMessageCount">
<tt class="descname">getMessageCount</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.getMessageCount" title="Permalink to this definition"></a></dt>
<dd><p>How many times sendMessage() was called since beginning of run</p>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.isSubscribed">
<tt class="descname">isSubscribed</tt><big>(</big><em>listener</em>, <em>topic=None</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.isSubscribed" title="Permalink to this definition"></a></dt>
<dd><p>Return true if listener has subscribed to topic specified. 
If no topic specified, return true if subscribed to something.
Use topic=getStrAllTopics() to determine if a listener will receive 
messages for all topics.</p>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.isValid">
<tt class="descname">isValid</tt><big>(</big><em>listener</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.isValid" title="Permalink to this definition"></a></dt>
<dd><p>Return true only if listener will be able to subscribe to 
Publisher.</p>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.sendMessage">
<tt class="descname">sendMessage</tt><big>(</big><em>topic=''</em>, <em>data=None</em>, <em>onTopicNeverCreated=None</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.sendMessage" title="Permalink to this definition"></a></dt>
<dd><p>Send a message for given topic, with optional data, to
subscribed listeners. If topic is not specified, only the
listeners that are interested in all topics will receive message. 
The onTopicNeverCreated is an optional callback of your choice that 
will be called if the topic given was never created (i.e. it, or 
one of its subtopics, was never subscribed to by any listener). 
It will be called as onTopicNeverCreated(topic).</p>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.subscribe">
<tt class="descname">subscribe</tt><big>(</big><em>listener</em>, <em>topic=''</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.subscribe" title="Permalink to this definition"></a></dt>
<dd><p>Subscribe listener for given topic. If topic is not specified,
listener will be subscribed for all topics (that listener will 
receive a Message for any topic for which a message is generated).</p>
<p>This method may be called multiple times for one listener,
registering it with many topics.  It can also be invoked many
times for a particular topic, each time with a different
listener.  See the class doc for requirements on listener and
topic.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Note :</th><td class="field-body"><p class="first">The listener is held by Publisher() only by <em>weak</em>
reference.  This means you must ensure you have at
least one strong reference to listener, otherwise it
will be DOA (&#8220;dead on arrival&#8221;). This is particularly
easy to forget when wrapping a listener method in a
proxy object (e.g. to bind some of its parameters),
e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Foo</span><span class="p">:</span> 
    <span class="k">def</span> <span class="nf">listener</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span> <span class="k">pass</span>
<span class="k">class</span> <span class="nc">Wrapper</span><span class="p">:</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fun</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">fun</span> <span class="o">=</span> <span class="n">fun</span>
    <span class="k">def</span> <span class="nf">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">fun</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
<span class="n">foo</span> <span class="o">=</span> <span class="n">Foo</span><span class="p">()</span>
<span class="n">Publisher</span><span class="p">()</span><span class="o">.</span><span class="n">subscribe</span><span class="p">(</span> <span class="n">Wrapper</span><span class="p">(</span><span class="n">foo</span><span class="o">.</span><span class="n">listener</span><span class="p">)</span> <span class="p">)</span> <span class="c"># whoops: DOA!</span>
<span class="n">wrapper</span> <span class="o">=</span> <span class="n">Wrapper</span><span class="p">(</span><span class="n">foo</span><span class="o">.</span><span class="n">listener</span><span class="p">)</span>
<span class="n">Publisher</span><span class="p">()</span><span class="o">.</span><span class="n">subscribe</span><span class="p">(</span><span class="n">wrapper</span><span class="p">)</span> <span class="c"># good!</span>
</pre></div>
</div>
</td>
</tr>
<tr class="field"><th class="field-name">Note :</th><td class="field-body"><p class="first last">Calling this method for the same listener, with two
topics in the same branch of the topic hierarchy, will
cause the listener to be notified twice when a message
for the deepest topic is sent. E.g.
subscribe(listener, &#8216;t1&#8217;) and then subscribe(listener,
(&#8216;t1&#8217;,&#8217;t2&#8217;)) means that when calling sendMessage(&#8216;t1&#8217;),
listener gets one message, but when calling
sendMessage((&#8216;t1&#8217;,&#8217;t2&#8217;)), listener gets message twice.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.unsubAll">
<tt class="descname">unsubAll</tt><big>(</big><em>topics=None</em>, <em>onNoSuchTopic=None</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.unsubAll" title="Permalink to this definition"></a></dt>
<dd><p>Unsubscribe all listeners subscribed for topics. Topics can 
be a single topic (string or tuple) or a list of topics (ie 
list containing strings and/or tuples). If topics is not 
specified, all listeners for all topics will be unsubscribed, 
ie. the Publisher singleton will have no topics and no listeners
left. If onNoSuchTopic is given, it will be called as 
onNoSuchTopic(topic) for each topic that is unknown.</p>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.unsubscribe">
<tt class="descname">unsubscribe</tt><big>(</big><em>listener</em>, <em>topics=None</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.unsubscribe" title="Permalink to this definition"></a></dt>
<dd><p>Unsubscribe listener. If topics not specified, listener is
completely unsubscribed. Otherwise, it is unsubscribed only 
for the topic (the usual tuple) or list of topics (ie a list
of tuples) specified. Nothing happens if listener is not actually
subscribed to any of the topics.</p>
<p>Note that if listener subscribed for two topics (a,b) and (a,c), 
then unsubscribing for topic (a) will do nothing. You must 
use getAssociatedTopics(listener) and give unsubscribe() the returned 
list (or a subset thereof).</p>
</dd></dl>

<dl class="method">
<dt id="other.pubsub.PublisherClass.validate">
<tt class="descname">validate</tt><big>(</big><em>listener</em><big>)</big><a class="headerlink" href="#other.pubsub.PublisherClass.validate" title="Permalink to this definition"></a></dt>
<dd><p>Similar to isValid(), but raises a TypeError exception if not valid</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="other.pubsub.getStrAllTopics">
<tt class="descclassname">other.pubsub.</tt><tt class="descname">getStrAllTopics</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pubsub.getStrAllTopics" title="Permalink to this definition"></a></dt>
<dd><p>Function to call if, for whatever reason, you need to know 
explicitely what is the string to use to indicate &#8216;all topics&#8217;.</p>
</dd></dl>

<dl class="function">
<dt id="other.pubsub.test">
<tt class="descclassname">other.pubsub.</tt><tt class="descname">test</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pubsub.test" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="other.pil_1_1_6.TiffImagePlugin.html"
                        title="previous chapter">TiffImagePlugin</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="other.pyWx.html"
                        title="next chapter">pyWx</a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="other.pyWx.html" title="pyWx"
             >next</a> |</li>
        <li class="right" >
          <a href="other.pil_1_1_6.TiffImagePlugin.html" title="TiffImagePlugin"
             >previous</a> |</li>
        <li><a href="index.html">Phatch v0.2 documentation</a> &raquo;</li>
          <li><a href="other.html" >other</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009, www.stani.be.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>