API Documentation

Classes

SessionDataManagerInterface , BrowserIdManagerInterface , BrowserIdManagerErr , SessionDataManagerErr

Session APIs

See Also


class SessionDataManagerInterface

Zope Session Data Manager interface.

A Zope Session Data Manager is responsible for maintaining Session Data Objects, and for servicing requests from application code related to Session Data Objects. It also communicates with a Browser Id Manager to provide information about browser ids.


Methods

hasSessionData():

Returns true if a Session Data Object associated with the current browser id is found in the Session Data Container. Does not create a Session Data Object if one does not exist.

Permission required: Access session data

getBrowserIdManager():

Returns the nearest acquirable browser id manager.

Raises SessionDataManagerErr if no browser id manager can be found.

Permission required: Access session data

getSessionData(create=1):

Returns a Session Data Object associated with the current browser id. If there is no current browser id, and create is true, returns a new Session Data Object. If there is no current browser id and create is false, returns None.

Permission required: Access session data

getSessionDataByKey(key):

Returns a Session Data Object associated with key. If there is no Session Data Object associated with key return None.

Permission required: Access arbitrary user session data


class BrowserIdManagerInterface

Zope Browser Id Manager interface.

A Zope Browser Id Manager is responsible for assigning ids to site visitors, and for servicing requests from Session Data Managers related to the browser id.


Methods

hasBrowserId():

Returns true if there is a browser id for this request.

Permission required: Access contents information

getHiddenFormField():

Returns a string in the form:

Where the name and the value represent the current browser id name and current browser id.

isBrowserIdFromForm():

Returns true if browser id comes from a form variable (query string or post).

Permission required: Access contents information

Raises: BrowserIdManagerErr. If there is no current browser id.

isBrowserIdNew():

Returns true if browser id is new. A browser id is new when it is first created and the client has therefore not sent it back to the server in any request.

Permission required: Access contents information

Raises: BrowserIdManagerErr. If there is no current browser id.

isBrowserIdFromCookie():

Returns true if browser id comes from a cookie.

Permission required: Access contents information

Raises: BrowserIdManagerErr. If there is no current browser id.

setBrowserIdCookieByForce(bid):

Sets the browser id cookie to browser id bid by force. Useful when you need to chain browser id cookies across domains for the same user (perhaps temporarily using query strings).

Permission required: Access contents information

Raises: BrowserIdManagerErr. If the cookies namespace isn't a browser id namespace at the time of the call.

getBrowserIdName():

Returns a string with the name of the cookie/form variable which is used by the current browser id manager as the name to look up when attempting to obtain the browser id value. For example, _ZopeId.

Permission required: Access contents information

flushBrowserIdCookie():

Deletes the browser id cookie from the client browser, iff the cookies browser id namespace is being used.

Permission required: Access contents information

Raises: BrowserIdManagerErr. If the cookies namespace isn't a browser id namespace at the time of the call.

encodeUrl(url, style=querystring):

Encodes a provided URL with the current request's browser id and returns the result. Two forms of URL-encoding are supported: querystring and inline. querystring is the default.

If the querystring form is used, the browser id name/value pair are postfixed onto the URL as a query string. If the inline form is used, the browser id name/value pair are prefixed onto the URL as the first two path segment elements.

For example:

The call encodeUrl(http://foo.com/amethod, style=querystring) might return http://foo.com/amethod?_ZopeId=as9dfu0adfu0ad.

The call encodeUrl('http://foo.com/amethod, style=inline) might return http://foo.com/_ZopeId/as9dfu0adfu0ad/amethod.

Permission required: Access contents information

Raises: BrowserIdManagerErr. If there is no current browser id.

getBrowserId(create=1):

If create=0, returns a the current browser id or None if there is no browser id associated with the current request. If create=1, returns the current browser id or a newly-created browser id if there is no browser id associated with the current request. This method is useful in conjunction with getBrowserIdName if you wish to embed the browser-id-name/browser-id combination as a hidden value in a POST-based form. The browser id is opaque, has no business meaning, and its length, type, and composition are subject to change.

Permission required: Access contents information

Raises: BrowserIdManagerErr. If ill-formed browser id is found in REQUEST.


class BrowserIdManagerErr

Error raised during some browser id manager operations, as explained in the API documentation of the Browser Id Manager.

This exception may be caught in PythonScripts. A successful import of the exception for PythonScript use would need to be:

   from Products.Sessions import BrowserIdManagerErr


class SessionDataManagerErr

Error raised during some session data manager operations, as explained in the API documentation of the Session Data Manager.

This exception may be caught in PythonScripts. A successful import of the exception for PythonScript use would need to be:

   from Products.Sessions import SessionDataManagerErr