plone.api.env#

Module provides info about your instance and tools to switch roles and user.

plone.api.env.adopt_roles(roles=None)[source]#

Context manager for temporarily switching roles.

Parameters

roles (list of strings) -- New roles to gain inside block. Existing roles will be lost.

Example

Switch roles inside a block

plone.api.env.adopt_user(username=None, user=None)[source]#

Context manager for temporarily switching user inside a block.

Parameters
  • user (user object from acl_users.getUser() or api.user.get().) -- User object to switch to inside block.

  • username (string) -- username of user to switch to inside block.

Example

Switch user inside a block

plone.api.env.debug_mode()[source]#

Return True if your zope instance is running in debug mode.

Example

Debug mode

plone.api.env.plone_version()[source]#

Return Plone version number.

Returns

string denoting what release of Plone this distribution contains

Example

Plone version

plone.api.env.read_only_mode()[source]#

Check if the Zope instance is running on a read-only ZODB.

Returns

bool isReadOnly True if ZODB is read-only

Example

Read-Only mode

plone.api.env.test_mode()[source]#

Returns True if you are running the zope test runner.

Example

Test mode

plone.api.env.zope_version()[source]#

Return Zope 2 version number.

Returns

string denoting what release of Zope2 this distribution contains

Example

Zope version