Closed twisted-trac closed 20 years ago
Automation removed owner |
---|
@radix commented |
---|
#!html
<pre>
From
http://twistedmatrix.com/pipermail/twisted-python/2003-June/004582.html
* move Service to new module
* write TCPListenerService, SSLConnectService, etc
* write backwards-compatible listen|connectTCP/SSL/etc
* update _all_ uses of app.(listen|connect)
(TCP|SSL|UNIX) in Twisted.
* write upgrade function to upgrade Application's
mutable state.
</pre>
@itamarst commented |
---|
#!html
<pre>
The replacement would be some sort of TCPListenerService.
glyph had some thoughts on how the structure should work
(something to do with a heirarchy of services?).
The replacement will still have to allow make writing tap
plugins easy. Probably a tap should add a top-level service
with the tcp etc. listeners attached to it as subservices or
some such.
</pre>
m@... commented |
---|
#!html
<pre>
On Sun, 27 Jul 2003, Glyph Lefkowitz <twisted.roundup@...> wrote:
> Looks like moshez has volunteered for this one - see
> sandbox/moshez/application.py :-)
Actually, sandbox/moshez/application/
Summary of status:
It's in perfectly usable condition. To use it, move the directory to
twisted/
convert.convert creates new-style applications out of old ones
compat.IOldApplication will wrap new-style applications in an API
which allows the listen* and connect* methods to be used, and even more
importantly, allows twistd -y to be used.
Note that the convertor is not complete, and inparticular it
does not support authorizers. That's because new-style applications
don't support authorizers. So, what's left?
* Wait for old cred to die out, this design it completely unusable
with old cred [it's possible to change it, but I'd prefer to wait]
* Figure out how to update tap modules. Basically, all taps will have
to change.
* Attempt to get twistd to support both styles -- this can happen,
for example, by converting any other application object.
* It would be nice for twistd to actually depend on an API on
which it depends, so 3rd party application-like objects will be possible.
I'm not saying it's a good idea to write them, but twistd should
support them explicitly if it supports them implicitly.
The last item is not the magic it seems to be -- the API will be more
sophisticated than what the current application is capable of, so this
will not be the way for backwards compatibility. Or maybe I'm wrong.
In any case, I'll work on the API for the new twistd next.
--
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/
</pre>
@moshez commented |
---|
#!html
<pre>
Oh, also, another thing:
1. words -- it is crufty and uses old-pb and so old-application.
it can still run in compat mode, but I suggest fix or destroy
2. manhole -- ditto.
I suggest that words be destroyed. manhole might be useful to get fixed, though,
if some pb guru feels like it.
</pre>
@moshez commented |
---|
#!html
<pre>
Here's a patch to manhole:
Index: twisted/manhole/service.py
===================================================================
RCS file: /cvs/Twisted/twisted/manhole/service.py,v
retrieving revision 1.37
diff -u -r1.37 service.py
--- twisted/manhole/service.py 18 Feb 2003 21:15:30 -0000 1.37
+++ twisted/manhole/service.py 8 Oct 2003 05:46:36 -0000
@@ -22,6 +22,7 @@
from twisted import copyright
from twisted.spread import pb
from twisted.python import log, components, failure
+from twisted.cred import portal
# sibling imports
import explorer
@@ -199,12 +200,13 @@
class Perspective(pb.Perspective):
lastDeferred = 0
- def __init__(self, perspectiveName, identityName="Nobody"):
+ def __init__(self, service, perspectiveName, identityName="Nobody"):
pb.Perspective.__init__(self, perspectiveName, identityName)
self.localNamespace = {
"_": None,
}
self.clients = {}
+ self.service = service
def __getstate__(self):
state = self.__dict__.copy()
@@ -213,10 +215,6 @@
del state['localNamespace']['__builtins__']
return state
- def setService(self, service):
- pb.Perspective.setService(self, service)
- # self.browser.globalNamespace = service.namespace
-
def attached(self, client, identity):
"""A client has attached -- welcome them and add them to the list.
"""
@@ -226,9 +224,6 @@
msg = self.service.welcomeMessage % {
'you': getattr(identity, 'name', str(identity)),
- 'serviceName': self.service.getServiceName(),
- 'app': getattr(self.service.application, 'name',
- "some application"),
'host': host,
'longversion': copyright.longversion,
}
@@ -366,18 +361,29 @@
self.receiveExplorer)
-class Service(pb.Service):
- perspectiveClass = Perspective
- serviceType = "manhole"
+class Realm:
+
+ __implements__ = portal.IRealm
+
+ def __init__(self, service):
+ self.service = service
+
+ def requestAvatar(self, avatarId, mind, *interfaces):
+ if pb.IPerspective in interfaces:
+ return (pb.IPerspective,
+ Perspective(service, "manhole", avatarId),
+ lambda : None)
+ else:
+ raise NotImplementedError("no interface")
+
+class Service:
welcomeMessage = (
- "\nHello %(you)s, welcome to %(serviceName)s "
- "in %(app)s on %(host)s.\n"
+ "\nHello %(you)s, welcome to Manhole "
+ "on %(host)s.\n"
"%(longversion)s.\n\n")
- def __init__(self, serviceName='twisted.manhole', serviceParent=None, authorizer=None):
- pb.Service.__init__(self, serviceName, serviceParent, authorizer)
-
+ def __init__(self):
self.namespace = {
# I'd specify __name__ so we don't get it from __builtins__,
# but that seems to have the potential for breaking imports.
@@ -391,15 +397,9 @@
"""
# TODO -- refactor this and twisted.reality.author.Author to
# use common functionality (perhaps the 'code' module?)
- dict = pb.Service.__getstate__(self)
+ dict = self.__dict__.copy()
ns = dict['namespace'].copy()
dict['namespace'] = ns
if ns.has_key('__builtins__'):
del ns['__builtins__']
return dict
-
- def __str__(self):
- s = "<%s in application \'%s\'>" % (self.getServiceName(),
- getattr(self.application,
- 'name', "???"))
- return s
Index: twisted/tap/manhole.py
===================================================================
RCS file: /cvs/Twisted/twisted/tap/manhole.py,v
retrieving revision 1.25
diff -u -r1.25 manhole.py
--- twisted/tap/manhole.py 11 Apr 2003 18:54:12 -0000 1.25
+++ twisted/tap/manhole.py 8 Oct 2003 05:46:36 -0000
@@ -20,20 +20,19 @@
"""
from twisted.manhole import service
-from twisted.cred import authorizer
from twisted.spread import pb
from twisted.python import usage, util
+from twisted.cred import portal, checkers
+from twisted.application import strports
import os, sys
class Options(usage.Options):
synopsis = "mktap manhole [options]"
- optParameters = [["user", "u", "admin", "Name of user to allow to log in"]]
- def opt_port(self, opt):
- try:
- self['port'] = int(opt)
- except ValueError:
- raise usage.error("Invalid argument to 'port'!")
+ optParameters = [
+ ["user", "u", "admin", "Name of user to allow to log in"],
+ ["port", "p", str(pb.portno), "Port to listen on"]
+ ]
def opt_password(self, password):
"""Required. '-' will prompt or read a password from stdin.
@@ -45,23 +44,18 @@
self['password'] = util.getPassword(confirm=1)
else:
self['password'] = password
+ opt_w = opt_password
def postOptions(self):
if not self.has_key('password'):
self.opt_password('-')
- opt_p = opt_port
- opt_w = opt_password
-def updateApplication(app, config):
- auth = authorizer.DefaultAuthorizer(app)
- svc = service.Service("twisted.manhole", serviceParent=app,
- authorizer=auth)
- p = svc.createPerspective(config['user'])
- p.makeIdentity(config['password'])
- try:
- portno = config['port']
- except KeyError:
- portno = pb.portno
- app.listenTCP(portno, pb.BrokerFactory(pb.AuthRoot(auth)))
+def makeService(config):
+ realm = service.Realm(service.Service())
+ p = portal.Portal(realm)
+ checker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
+ checker.addUser(config['user'], config['password'])
+ p.registerChecker(checker)
+ return strports.service(config['port'], pb.PBServerFactory(p))
</pre>
@itamarst commented |
---|
#!html
<pre>
Status update: main howtos have been rewritten, examples are updated, remaining
are manhole, words, and a few more of the howtos (e.g. PB ones, but that'll be
fixed as part of the PB docs update.)
The core application code and howtos being finished, I am marking this fixed.
Any remaining issues should be fixed directly or added as new issues (e.g.
manhole has its own issue).
</pre>
Searchable metadata
``` trac-id__67 67 type__defect defect reporter__itamarst itamarst priority__highest highest milestone__ branch__ branch_author__ status__closed closed resolution__fixed fixed component__ftp ftp keywords__ time__1058183701000000 1058183701000000 changetime__1065904326000000 1065904326000000 version__ owner__ cc__glyph cc__radix cc__itamarst cc__moshez ```