Skip to content

Commit fb6ef28

Browse files
committed
Complete the rename.
1 parent 19b3355 commit fb6ef28

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

doc/tutorial3.rst

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ example::
7676

7777
The receiver factory is a two-argument callable which is passed the constructed
7878
sender and the ``ParserProtocol`` instance. The returned object must at least
79-
have ``connectionMade`` and ``connectionLost`` methods. These are called at the
80-
same time as the same-named methods on the ``ParserProtocol``.
79+
have ``prepareParsing`` and ``finishParsing`` methods. ``prepareParsing`` is
80+
called when a connection is established (i.e. in the ``connectionMade`` of the
81+
``ParserProtocol``) and ``finishParsing`` is called when a connection is closed
82+
(i.e. in the ``connectionLost`` of the ``ParserProtocol``).
8183

8284
.. note::
83-
Both the receiver factory and its returned object's ``connectionMade`` are
85+
Both the receiver factory and its returned object's ``prepareParsing`` are
8486
called at in the ``ParserProtocol``'s ``connectionMade`` method; this
8587
separation is for ease of testing receivers.
8688

@@ -91,10 +93,10 @@ and echos the same netstrings back::
9193
def __init__(self, sender, parser):
9294
self.sender = sender
9395

94-
def connectionMade(self):
96+
def prepareParsing(self):
9597
pass
9698

97-
def connectionLost(self, reason):
99+
def finishParsing(self, reason):
98100
pass
99101

100102
def netstringReceived(self, string):
@@ -141,10 +143,10 @@ And finally, a complete example::
141143
def __init__(self, sender, parser):
142144
self.sender = sender
143145

144-
def connectionMade(self):
146+
def prepareParsing(self):
145147
pass
146148

147-
def connectionLost(self, reason):
149+
def finishParsing(self, reason):
148150
pass
149151

150152
def netstringReceived(self, string):
@@ -175,7 +177,7 @@ Intermezzo: error reporting
175177
If an exception is raised from within Parsley during parsing, whether it's due
176178
to input not matching the current rule or an exception being raised from code
177179
the grammar calls, the connection will be immediately closed. The traceback
178-
will be captured as a `Failure`_ and passed to the ``connectionLost`` method of
180+
will be captured as a `Failure`_ and passed to the ``finishParsing`` method of
179181
the receiver.
180182

181183
At present, there is no way to recover from failure.
@@ -234,10 +236,10 @@ The corresponding receiver and again, constructing the Protocol::
234236
def __init__(self, sender, parser):
235237
self.sender = sender
236238

237-
def connectionMade(self):
239+
def prepareParsing(self):
238240
pass
239241

240-
def connectionLost(self, reason):
242+
def finishParsing(self, reason):
241243
pass
242244

243245
def netstringFirstHalfReceived(self, string):
@@ -280,7 +282,7 @@ of a receiver for netstrings2::
280282
self.sender = sender
281283
self.parser = parser
282284

283-
def connectionMade(self):
285+
def prepareParsing(self):
284286
self.parser.setNextRule('colon')
285287

286288
In our case calling ``setNextRule`` is required before parsing begins since
@@ -290,7 +292,7 @@ to match against a nonexistant rule and fail.
290292
.. note::
291293

292294
It doesn't matter if ``setNextRule`` is called in ``__init__`` or
293-
``connectionMade`` to set the starting rule as long as it's called in one of
295+
``prepareParsing`` to set the starting rule as long as it's called in one of
294296
them (or something called by one of them).
295297

296298
The other way to change the current rule is to make the current rule evaluate
@@ -318,7 +320,7 @@ The same effect can be achieved with ``setNextRule``::
318320

319321
``setNextRule`` can be called at any time. However, if ``setNextRule`` is
320322
called from somewhere other than the receiver factory, its
321-
``connectionMade``, or a method called from the grammar, Parsley will wait
323+
``prepareParsing``, or a method called from the grammar, Parsley will wait
322324
until the current rule is completely matched before switching rules.
323325

324326

0 commit comments

Comments
 (0)