Changeset 6372 for main/waeup.sirp/trunk
- Timestamp:
- 15 Jun 2011, 23:19:58 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py
r6113 r6372 12 12 from zope.schema import getFieldNames 13 13 from zope.schema.fieldproperty import FieldProperty 14 from zope.security.interfaces import NoInteraction 15 from zope.security.management import getInteraction 16 14 17 15 18 def removeFileOrDirectory(filepath): … … 363 366 setattr(cls, field_name, FieldProperty(iface[field_name])) 364 367 return cls 368 369 def get_current_principal(): 370 """Get the 'current' principal. 371 372 This method works without a request. Examining a request is the 373 regular (and recommended) way to get a principal involved 374 'currently'. 375 376 Use this method only if you really have no access to the current 377 request. 378 379 Returns ``None`` when no principal is involved (for instance 380 during tests). 381 """ 382 try: 383 principal = getInteraction().participations[0].principal 384 except NoInteraction: 385 return None 386 except IndexError: # No participations present 387 return None 388 return principal
Note: See TracChangeset for help on using the changeset viewer.