|
690.
|
|
|
The factory-creation methods, <code>getFingerFactory</code> and <code>getFingerSetterFactory</code>, follow this pattern:
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:56
|
|
691.
|
|
|
Instantiate a generic server factory, <code>twisted.internet.protocol.ServerFactory</code>.
|
|
|
type: Content of: <html><body><ol><li>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:61
|
|
692.
|
|
|
Set the protocol class, just like our factory class would have.
|
|
|
type: Content of: <html><body><ol><li>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:64
|
|
693.
|
|
|
Copy a service method to the factory as a function attribute. The function won't have access to the factory's <code>self</code>, but that's OK because as a bound method it has access to the service's <code>self</code>, which is what it needs. For <code>getUser</code>, a custom method defined in the service gets copied. For <code>setUser</code>, a standard method of the <code>users</code> dictionary is copied.
|
|
|
type: Content of: <html><body><ol><li>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:66
|
|
694.
|
|
|
Thus, we stopped subclassing: the service simply puts useful methods and attributes inside the factories. We are getting better at protocol design: none of our protocol classes had to be changed, and neither will have to change until the end of the tutorial.
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:75
|
|
695.
|
|
|
As an application <code class="API" base="twisted.application.service">service</code> , this new finger service implements the <code class="API" base="twisted.application.service">IService</code> interface and can be started and stopped in a standardized manner. We'll make use of this in the next example.
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:80
|
|
696.
|
|
|
<a href="listings/finger/finger13.tac" class="py-listing">finger13.tac</a>
|
|
|
type: Content of: <html><body>
|
|
|
|
<a href="listings/finger/finger13.tac" class="py-listing">finger13.tac</a>
|
|
Translated and reviewed by
Kevin
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:87
|
|
697.
|
|
|
Read Status File
|
|
|
type: Content of: <html><body><h2>
|
|
|
|
读取状态文件
|
|
Translated by
Kevin
|
|
Reviewed by
Liu, Kun
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:91
|
|
698.
|
|
|
This version shows how, instead of just letting users set their messages, we can read those from a centrally managed file. We cache results, and every 30 seconds we refresh it. Services are useful for such scheduled tasks.
|
|
|
type: Content of: <html><body><p>
|
|
|
|
(no translation yet)
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:93
|
|
699.
|
|
|
<a href="listings/finger/etc.users" class="listing">sample /etc/users file</a> <a href="listings/finger/finger14.tac" class="py-listing">finger14.tac</a>
|
|
|
type: Content of: <html><body>
|
|
|
|
<a href="listings/finger/etc.users" class="listing">简单的 /etc/users 文件</a> <a href="listings/finger/finger14.tac" class="py-listing">finger14.tac</a>
|
|
Translated and reviewed by
Kevin
|
|
|
|
Located in
howto/tutorial/protocol.xhtml:98
|