equal
deleted
inserted
replaced
26 from zope.security.management import getInteraction |
26 from zope.security.management import getInteraction |
27 |
27 |
28 # import local packages |
28 # import local packages |
29 |
29 |
30 from ztfy.utils import _ |
30 from ztfy.utils import _ |
|
31 from zope.security.interfaces import NoInteraction |
31 |
32 |
32 |
33 |
33 def getRequest(): |
34 def getRequest(): |
34 """Extract request from current interaction""" |
35 """Extract request from current interaction""" |
35 interaction = getInteraction() |
36 interaction = getInteraction() |
36 for participation in interaction.participations: |
37 for participation in interaction.participations: |
37 if IRequest.providedBy(participation): |
38 if IRequest.providedBy(participation): |
38 return participation |
39 return participation |
39 raise RuntimeError, _("No Request in interaction !") |
40 raise RuntimeError, _("No Request in interaction !") |
|
41 |
|
42 |
|
43 def queryRequest(): |
|
44 try: |
|
45 return getRequest() |
|
46 except NoInteraction: |
|
47 return None |
40 |
48 |
41 |
49 |
42 def getRequestPrincipal(request=None): |
50 def getRequestPrincipal(request=None): |
43 """Get principal from given request""" |
51 """Get principal from given request""" |
44 if request is None: |
52 if request is None: |