43 """Get principal from given request""" |
43 """Get principal from given request""" |
44 if request is None: |
44 if request is None: |
45 request = getRequest() |
45 request = getRequest() |
46 return request.principal |
46 return request.principal |
47 |
47 |
|
48 getPrincipal = getRequestPrincipal |
|
49 |
48 |
50 |
49 def getRequestAnnotations(request=None): |
51 def getRequestAnnotations(request=None): |
50 """Get annotations from given request""" |
52 """Get annotations from given request""" |
51 if request is None: |
53 if request is None: |
52 request = getRequest() |
54 request = getRequest() |
53 return IAnnotations(request) |
55 return IAnnotations(request) |
|
56 |
|
57 getAnnotations = getRequestAnnotations |
54 |
58 |
55 |
59 |
56 def getRequestData(key, request=None, default=None): |
60 def getRequestData(key, request=None, default=None): |
57 """Get request data, stored into request annotations""" |
61 """Get request data, stored into request annotations""" |
58 try: |
62 try: |
59 annotations = getRequestAnnotations(request) |
63 annotations = getRequestAnnotations(request) |
60 return annotations.get(key, default) |
64 return annotations.get(key, default) |
61 except: |
65 except: |
62 return default |
66 return default |
63 |
67 |
|
68 getData = getRequestData |
|
69 |
64 |
70 |
65 def setRequestData(key, data, request=None): |
71 def setRequestData(key, data, request=None): |
66 """Define request data, stored into request annotations""" |
72 """Define request data, stored into request annotations""" |
67 annotations = getRequestAnnotations(request) |
73 annotations = getRequestAnnotations(request) |
68 annotations[key] = data |
74 annotations[key] = data |
|
75 |
|
76 setData = setRequestData |