~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: Jelmer Vernooij
  • Date: 2011-02-20 13:34:07 UTC
  • mto: (5622.4.1 uninstall-hook)
  • mto: This revision was merged to the branch mainline in revision 5747.
  • Revision ID: jelmer@samba.org-20110220133407-zhgrvuhhc1e3j2fn
Add more lazily usable hook points.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import sys
23
23
import threading
24
24
 
25
 
from bzrlib.hooks import HookPoint, Hooks
 
25
from bzrlib.hooks import Hooks
26
26
from bzrlib import (
27
27
    errors,
28
28
    trace,
233
233
class SmartServerHooks(Hooks):
234
234
    """Hooks for the smart server."""
235
235
 
236
 
    def __init__(self):
 
236
    def __init__(self, module_name, member_name):
237
237
        """Create the default hooks.
238
238
 
239
239
        These are all empty initially, because by default nothing should get
240
240
        notified.
241
241
        """
242
 
        Hooks.__init__(self)
243
 
        self.create_hook(HookPoint('server_started',
 
242
        Hooks.__init__(self, module_name, member_name)
 
243
        self.add_hook('server_started',
244
244
            "Called by the bzr server when it starts serving a directory. "
245
245
            "server_started is called with (backing urls, public url), "
246
246
            "where backing_url is a list of URLs giving the "
247
247
            "server-specific directory locations, and public_url is the "
248
 
            "public URL for the directory being served.", (0, 16), None))
249
 
        self.create_hook(HookPoint('server_started_ex',
 
248
            "public URL for the directory being served.", (0, 16))
 
249
        self.add_hook('server_started_ex',
250
250
            "Called by the bzr server when it starts serving a directory. "
251
251
            "server_started is called with (backing_urls, server_obj).",
252
 
            (1, 17), None))
253
 
        self.create_hook(HookPoint('server_stopped',
 
252
            (1, 17))
 
253
        self.add_hook('server_stopped',
254
254
            "Called by the bzr server when it stops serving a directory. "
255
255
            "server_stopped is called with the same parameters as the "
256
 
            "server_started hook: (backing_urls, public_url).", (0, 16), None))
 
256
            "server_started hook: (backing_urls, public_url).", (0, 16))
257
257
 
258
 
SmartTCPServer.hooks = SmartServerHooks()
 
258
SmartTCPServer.hooks = SmartServerHooks("bzrlib.smart.server", "SmartTCPServer.hooks")
259
259
 
260
260
 
261
261
def _local_path_for_transport(transport):