~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: Robert Collins
  • Date: 2007-07-20 03:20:20 UTC
  • mfrom: (2592 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2635.
  • Revision ID: robertc@robertcollins.net-20070720032020-xiftpb5gqeebo861
(robertc) Reinstate the accidentally backed out external_url patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from bzrlib.hooks import Hooks
24
24
from bzrlib import (
 
25
    errors,
25
26
    trace,
26
27
    transport,
27
28
)
65
66
 
66
67
    def serve(self):
67
68
        self._should_terminate = False
 
69
        # for hooks we are letting code know that a server has started (and
 
70
        # later stopped).
 
71
        # There are three interesting urls:
 
72
        # The URL the server can be contacted on. (e.g. bzr://host/)
 
73
        # The URL that a commit done on the same machine as the server will
 
74
        # have within the servers space. (e.g. file:///home/user/source)
 
75
        # The URL that will be given to other hooks in the same process -
 
76
        # the URL of the backing transport itself. (e.g. chroot+:///)
 
77
        # We need all three because:
 
78
        #  * other machines see the first
 
79
        #  * local commits on this machine should be able to be mapped to
 
80
        #    this server 
 
81
        #  * commits the server does itself need to be mapped across to this
 
82
        #    server.
 
83
        # The latter two urls are different aliases to the servers url,
 
84
        # so we group those in a list - as there might be more aliases 
 
85
        # in the future.
 
86
        backing_urls = [self.backing_transport.base]
 
87
        try:
 
88
            backing_urls.append(self.backing_transport.external_url())
 
89
        except errors.InProcessTransport:
 
90
            pass
68
91
        for hook in SmartTCPServer.hooks['server_started']:
69
 
            hook(self.backing_transport.base, self.get_url())
 
92
            hook(backing_urls, self.get_url())
70
93
        self._started.set()
71
94
        try:
72
95
            try:
100
123
                # ignore errors on close
101
124
                pass
102
125
            for hook in SmartTCPServer.hooks['server_stopped']:
103
 
                hook(self.backing_transport.base, self.get_url())
 
126
                hook(backing_urls, self.get_url())
104
127
 
105
128
    def get_url(self):
106
129
        """Return the url of the server"""
163
186
        Hooks.__init__(self)
164
187
        # Introduced in 0.16:
165
188
        # invoked whenever the server starts serving a directory.
166
 
        # The api signature is (backing url, public url).
 
189
        # The api signature is (backing urls, public url).
167
190
        self['server_started'] = []
168
191
        # Introduced in 0.16:
169
192
        # invoked whenever the server stops serving a directory.
170
 
        # The api signature is (backing url, public url).
 
193
        # The api signature is (backing urls, public url).
171
194
        self['server_stopped'] = []
172
195
 
173
196
SmartTCPServer.hooks = SmartServerHooks()