13 # |
13 # |
14 ############################################################################## |
14 ############################################################################## |
15 |
15 |
16 |
16 |
17 # import standard packages |
17 # import standard packages |
|
18 from cStringIO import StringIO |
18 |
19 |
19 # import Zope3 interfaces |
20 # import Zope3 interfaces |
20 from zope.annotation.interfaces import IAnnotations |
21 from zope.annotation.interfaces import IAnnotations |
21 from zope.publisher.interfaces import IRequest |
22 from zope.publisher.interfaces import IRequest |
22 from zope.security.interfaces import NoInteraction |
23 from zope.security.interfaces import NoInteraction, IParticipation, IPrincipal |
23 |
24 |
24 # import local interfaces |
25 # import local interfaces |
25 |
26 |
26 # import Zope3 packages |
27 # import Zope3 packages |
27 from zope.security.management import getInteraction |
28 from zope.interface import implements |
|
29 from zope.publisher.http import HTTPRequest |
|
30 from zope.security.management import getInteraction, newInteraction, endInteraction |
28 |
31 |
29 # import local packages |
32 # import local packages |
30 |
33 |
31 from ztfy.utils import _ |
34 from ztfy.utils import _ |
32 |
35 |
|
36 |
|
37 # |
|
38 # Participations functions |
|
39 # |
|
40 |
|
41 class Principal(object): |
|
42 """Basic principal""" |
|
43 |
|
44 implements(IPrincipal) |
|
45 |
|
46 def __init__(self, id, title=u'', description=u''): |
|
47 self.id = id |
|
48 self.title = title |
|
49 self.description = description |
|
50 |
|
51 |
|
52 class Participation(HTTPRequest): |
|
53 """Basic participation""" |
|
54 |
|
55 implements(IParticipation) |
|
56 |
|
57 def __init__(self, principal): |
|
58 super(Participation, self).__init__(StringIO(), {}) |
|
59 self.setPrincipal(principal) |
|
60 self.interaction = None |
|
61 |
|
62 |
|
63 def newParticipation(principal, title=u'', description=u''): |
|
64 principal = Principal(principal) |
|
65 newInteraction(Participation(principal)) |
|
66 |
|
67 |
|
68 def endParticipation(): |
|
69 endInteraction() |
|
70 |
|
71 |
|
72 # |
|
73 # Request handling functions |
|
74 # |
33 |
75 |
34 def getRequest(): |
76 def getRequest(): |
35 """Extract request from current interaction""" |
77 """Extract request from current interaction""" |
36 interaction = getInteraction() |
78 interaction = getInteraction() |
37 for participation in interaction.participations: |
79 for participation in interaction.participations: |