equal
deleted
inserted
replaced
15 |
15 |
16 |
16 |
17 # import standard packages |
17 # import standard packages |
18 |
18 |
19 # import Zope3 interfaces |
19 # import Zope3 interfaces |
|
20 from zope.annotation.interfaces import IAnnotations |
20 from zope.publisher.interfaces import IRequest |
21 from zope.publisher.interfaces import IRequest |
21 from zope.annotation.interfaces import IAnnotations |
22 from zope.security.interfaces import NoInteraction |
22 |
23 |
23 # import local interfaces |
24 # import local interfaces |
24 |
25 |
25 # import Zope3 packages |
26 # import Zope3 packages |
26 from zope.security.management import getInteraction |
27 from zope.security.management import getInteraction |
27 |
28 |
28 # import local packages |
29 # import local packages |
29 |
30 |
30 from ztfy.utils import _ |
31 from ztfy.utils import _ |
31 from zope.security.interfaces import NoInteraction |
|
32 |
32 |
33 |
33 |
34 def getRequest(): |
34 def getRequest(): |
35 """Extract request from current interaction""" |
35 """Extract request from current interaction""" |
36 interaction = getInteraction() |
36 interaction = getInteraction() |
41 |
41 |
42 |
42 |
43 def queryRequest(): |
43 def queryRequest(): |
44 try: |
44 try: |
45 return getRequest() |
45 return getRequest() |
46 except NoInteraction: |
46 except NoInteraction: # No current interaction |
|
47 return None |
|
48 except RuntimeError: # No request in interaction |
47 return None |
49 return None |
48 |
50 |
49 |
51 |
50 def getRequestPrincipal(request=None): |
52 def getRequestPrincipal(request=None): |
51 """Get principal from given request""" |
53 """Get principal from given request""" |