--- a/src/ztfy/utils/request.py Mon Sep 24 08:54:09 2012 +0200
+++ b/src/ztfy/utils/request.py Mon Sep 24 19:42:40 2012 +0200
@@ -15,22 +15,64 @@
# import standard packages
+from cStringIO import StringIO
# import Zope3 interfaces
from zope.annotation.interfaces import IAnnotations
from zope.publisher.interfaces import IRequest
-from zope.security.interfaces import NoInteraction
+from zope.security.interfaces import NoInteraction, IParticipation, IPrincipal
# import local interfaces
# import Zope3 packages
-from zope.security.management import getInteraction
+from zope.interface import implements
+from zope.publisher.http import HTTPRequest
+from zope.security.management import getInteraction, newInteraction, endInteraction
# import local packages
from ztfy.utils import _
+#
+# Participations functions
+#
+
+class Principal(object):
+ """Basic principal"""
+
+ implements(IPrincipal)
+
+ def __init__(self, id, title=u'', description=u''):
+ self.id = id
+ self.title = title
+ self.description = description
+
+
+class Participation(HTTPRequest):
+ """Basic participation"""
+
+ implements(IParticipation)
+
+ def __init__(self, principal):
+ super(Participation, self).__init__(StringIO(), {})
+ self.setPrincipal(principal)
+ self.interaction = None
+
+
+def newParticipation(principal, title=u'', description=u''):
+ principal = Principal(principal)
+ newInteraction(Participation(principal))
+
+
+def endParticipation():
+ endInteraction()
+
+
+#
+# Request handling functions
+#
+
def getRequest():
"""Extract request from current interaction"""
interaction = getInteraction()