Attachment 'ges.patch'

Download

   1 * looking for nirs@freeshell.org--2005/moin--fix--1.3--patch-27 to compare with
   2 * comparing to nirs@freeshell.org--2005/moin--fix--1.3--patch-27
   3 M  MoinMoin/server/twistedmoin.py
   4 M  MoinMoin/PageEditor.py
   5 
   6 * modified files
   7 
   8 --- orig/MoinMoin/PageEditor.py
   9 +++ mod/MoinMoin/PageEditor.py
  10 @@ -948,8 +948,19 @@
  11          # we broke his lock ==> but revision checking during preview will
  12          self.lock.release(force=not msg) # XXX does "not msg" make any sense?
  13    
  14 +        self.publish(wiki=self.request.cfg.sitename, page=self.page_name,
  15 +            action=action, user=self.request.user.name or '--anon--',
  16 +            comment=comment)
  17 +
  18          return msg
  19              
  20 +    def publish(self, **kw):
  21 +        if not (hasattr(self.request, 'publisher') and
  22 +                self.request.publisher.connected):
  23 +            return
  24 +        from MoinMoin.util import web
  25 +        text = web.makeQueryString(kw)
  26 +        self.request.publisher.connected.publish(text)
  27              
  28  class PageLock:
  29      """
  30 
  31 
  32 --- orig/MoinMoin/server/twistedmoin.py
  33 +++ mod/MoinMoin/server/twistedmoin.py
  34 @@ -24,7 +24,8 @@
  35  # Twisted imports
  36  from twisted.application import internet, service
  37  from twisted.web import script, static, server, vhost, resource, util
  38 -from twisted.internet import threads, reactor
  39 +from twisted.internet import threads, reactor, protocol
  40 +from twisted.protocols import irc
  41  
  42  # Enable threads
  43  from twisted.python import threadable
  44 @@ -42,6 +43,43 @@
  45  # Server globals
  46  config = None
  47  
  48 +
  49 +class IRCPublisherService(service.Service):
  50 +
  51 +    def getIRCBot(self, channel, nickname):
  52 +        """ Get irc bot factory connecting to channel """
  53 +        f = PublisherFactory()
  54 +        f.protocol, f.channel, f.nickname, = IRCPublisher, channel, nickname
  55 +        return f
  56 +
  57 +
  58 +class PublisherFactory(protocol.ReconnectingClientFactory):
  59 +    """ Create publishers """
  60 +    
  61 +    def __init__(self):
  62 +        self.connected = None
  63 +        
  64 +    def buildProtocol(self, addr):
  65 +        """Create publishers, one per channel """
  66 +        self.connected = protocol.ReconnectingClientFactory.buildProtocol(
  67 +            self, addr)
  68 +        return self.connected
  69 +
  70 +    def clientConnectionLost(self, connector, unused_reason):
  71 +        self.connected = None
  72 +        protocol.ReconnectingClientFactory.clientConnectionLost(self,
  73 +            connector, unused_reason)
  74 +
  75 +class IRCPublisher(irc.IRCClient):
  76 +    
  77 +    def connectionMade(self):
  78 +        self.nickname = self.factory.nickname
  79 +        irc.IRCClient.connectionMade(self)
  80 +        self.join(self.factory.channel)
  81 +
  82 +    def publish(self, text):
  83 +        self.say(self.factory.channel, text)
  84 +            
  85      
  86  class WikiResource(resource.Resource):
  87      """ Wiki resource """
  88 @@ -71,7 +109,8 @@
  89          else:
  90              if config.memoryProfile:
  91                  config.memoryProfile.addRequest()
  92 -            req = RequestTwisted(request, name, reactor)
  93 +            req = RequestTwisted(request, name, reactor, 
  94 +                                 {'publisher': config.publisher})
  95              if config.hotshotProfile:
  96                  threads.deferToThread(config.hotshotProfile.runcall, req.run)
  97              else:
  98 @@ -266,5 +305,12 @@
  99          s = internet.TCPServer(port, site, interface=interface)
 100          s.setServiceParent(sc)
 101  
 102 +    # Start IRC publisher
 103 +    config.publisher = IRCPublisherService().getIRCBot('#MoinMoinEvents',
 104 +                                                       "Nirs_Wiki")
 105 +    internet.TCPClient('irc.freenode.net', 6667,
 106 +                       config.publisher).setServiceParent(sc)
 107 +   
 108 +
 109      return application
 110  

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2005-04-29 13:16:22, 3.5 KB) [[attachment:ges.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.