[Hepserver-commits] hep/hep/services http.py,1.1,1.2
Status: Alpha
Brought to you by:
abefettig
|
From: <abe...@us...> - 2003-08-07 03:24:25
|
Update of /cvsroot/hepserver/hep/hep/services
In directory sc8-pr-cvs1:/tmp/cvs-serv14617/hep/services
Modified Files:
http.py
Log Message:
start of public pages for users who aren't
logged in
Index: http.py
===================================================================
RCS file: /cvsroot/hepserver/hep/hep/services/http.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** http.py 10 Jul 2003 16:09:36 -0000 1.1
--- http.py 7 Aug 2003 03:24:22 -0000 1.2
***************
*** 2,7 ****
from twisted.internet import app, reactor
import hep.web
- from hep.web.messages import MessagesPage
from hep.web.models import UserModel
from twisted.python.util import sibpath
--- 2,8 ----
from twisted.internet import app, reactor
import hep.web
from hep.web.models import UserModel
+ from hep.web.messages import MessagesPage
+ from twisted.web.util import Redirect
from twisted.python.util import sibpath
***************
*** 13,20 ****
# register an IResource interface with the data manager
dm = self.serviceParent.getServiceNamed('Data Manager')
! dm.avatarInterfaces[resource.IResource] = getResource
self.factory = getFactory(self.serviceParent)
reactor.listenTCP(self.PORT, self.factory)
def getFactory(app):
--- 14,28 ----
# register an IResource interface with the data manager
dm = self.serviceParent.getServiceNamed('Data Manager')
! dm.avatarInterfaces[resource.IResource] = self.getResource
self.factory = getFactory(self.serviceParent)
reactor.listenTCP(self.PORT, self.factory)
+
+ def getResource(self, user):
+ if user:
+ return UserResource(UserModel(user=user))
+ else:
+ anonUser = self.serviceParent.getServiceNamed('Data Manager').users['anonymous']
+ return UserResource(UserModel(user=anonUser))
def getFactory(app):
***************
*** 27,39 ****
res.putChild(staticPath, static.File(sibpath(hep.web.__file__, staticPath)))
! res.putChild("", static.Data("<html><a href='messages'>Messages</a>", "text/html"))
from twisted.web.woven.guard import UsernamePasswordWrapper, SessionWrapper
! res.putChild("messages", SessionWrapper(UsernamePasswordWrapper(portal)))
return site
! def getResource(user):
! if user:
! return MessagesPage(UserModel(user=user))
! else:
! return static.Data("anonymous browsing - <a href='perspective-init'>login</a>", "text/html")
!
\ No newline at end of file
--- 35,57 ----
res.putChild(staticPath, static.File(sibpath(hep.web.__file__, staticPath)))
! res.putChild("", Redirect("/messages"))
from twisted.web.woven.guard import UsernamePasswordWrapper, SessionWrapper
! res.putChild("messages", SessionWrapper(
! UsernamePasswordWrapper(portal))) #,lambda _: Redirect("/messages")))))
return site
! class UserResource(resource.Resource):
!
! def __init__(self, user):
! self.user = user
! resource.Resource.__init__(self)
!
! def render(self, request):
! print "RENDERNG!"
! request.redirect('/messages')
! return ""
!
! def getChild(self, name, request):
! #if name == 'messages':
! return MessagesPage(self.user)
!
\ No newline at end of file
|