CubicWeb is a generic framework to quickly build applications which describes relations between entitites.


Base exceptions#

exception cubicweb.ProgrammingError[source]#

Bases: Exception

Exception raised for errors that are related to the database’s operation and not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found, a transaction could not be processed, a memory allocation error occurred during processing, etc.

exception cubicweb.CubicWebException[source]#

Bases: Exception

base class for cubicweb server exception

exception cubicweb.InternalError[source]#

Bases: cubicweb._exceptions.CubicWebException

base class for exceptions which should not occur

exception cubicweb.SecurityError[source]#

Bases: cubicweb._exceptions.CubicWebException

base class for cubicweb server security exceptions

exception cubicweb.RepositoryError[source]#

Bases: cubicweb._exceptions.CubicWebException

base class for repository exceptions

exception cubicweb.SourceException[source]#

Bases: cubicweb._exceptions.CubicWebException

base class for source exceptions

exception cubicweb.CubicWebRuntimeError[source]#

Bases: cubicweb._exceptions.CubicWebException

base class for runtime exceptions

Repository exceptions#

exception cubicweb.ConnectionError[source]#

Bases: cubicweb._exceptions.RepositoryError

raised when a bad connection id is given or when an attempt to establish a connection failed

exception cubicweb.AuthenticationError[source]#

Bases: cubicweb._exceptions.ConnectionError

raised when an attempt to establish a connection failed due to wrong connection information (login / password or other authentication token)

exception cubicweb.BadConnectionId[source]#

Bases: cubicweb._exceptions.ConnectionError

raised when a bad connection id is given

exception cubicweb.UnknownEid[source]#

Bases: cubicweb._exceptions.RepositoryError

the eid is not defined in the system tables

exception cubicweb.UniqueTogetherError(session, **kwargs)[source]#

Bases: cubicweb._exceptions.RepositoryError

raised when a unique_together constraint caused an IntegrityError

Security Exceptions#

exception cubicweb.Unauthorized[source]#

Bases: cubicweb._exceptions.SecurityError

raised when a user tries to perform an action without sufficient credentials

exception cubicweb.Forbidden[source]#

Bases: cubicweb._exceptions.SecurityError

raised when a user tries to perform a forbidden action

Source exceptions#

exception cubicweb.EidNotInSource[source]#

Bases: cubicweb._exceptions.SourceException

trying to access an object with a particular eid from a particular source has failed

Registry exceptions#

exception cubicweb.UnknownProperty[source]#

Bases: logilab.common.registry.RegistryException

property found in database but unknown in registry

Query exceptions#

exception cubicweb.QueryError[source]#

Bases: cubicweb._exceptions.CubicWebRuntimeError

a query try to do something it shouldn’t

exception cubicweb.NotAnEntity[source]#

Bases: cubicweb._exceptions.CubicWebRuntimeError

raised when get_entity is called for a column which doesn’t contain a non final entity

exception cubicweb.MultipleResultsError[source]#

Bases: cubicweb._exceptions.CubicWebRuntimeError

raised when is called on a resultset with multiple rows of multiple columns.

exception cubicweb.NoResultError[source]#

Bases: cubicweb._exceptions.CubicWebRuntimeError

raised when no result is found but at least one is expected.

exception cubicweb.UndoTransactionException(txuuid, errors)[source]#

Bases: cubicweb._exceptions.QueryError

Raised when undoing a transaction could not be performed completely.

Note that :
  1. the partial undo operation might be acceptable depending upon the final application

  2. the undo operation can also fail with a ValidationError in cases where the undoing breaks integrity constraints checked immediately.

  3. It might be that neither of those exception is raised but a subsequent commit might raise a ValidationError in cases where the undoing breaks integrity constraints checked at commit time.

  • txuuid – Unique identifier of the partially undone transaction

  • errors (list) – List of errors occurred during undoing


exception cubicweb.ConfigurationError[source]#

Bases: cubicweb._exceptions.CubicWebException

a misconfiguration error

exception cubicweb.ExecutionError[source]#

Bases: Exception

server execution control error (already started, not running…)

exception cubicweb.BadCommandUsage[source]#

Bases: Exception

Raised when an unknown command is used or when a command is not correctly used (bad options, too much / missing arguments…).

Trigger display of command usage.

exception cubicweb.ValidationError(entity, errors: Dict, msgargs: Optional[Dict] = None, i18nvalues: Optional[List] = None)[source]#

Bases: yams._exceptions.SchemaError

Validation error details the reason(s) why the validation failed.

Arguments are:

  • entity: the entity that could not be validated; actual type depends on the client library

  • errors: errors dictionary, None key used for global error, other keys should be attribute/relation of the entity, qualified as subject/object using yams.role_name(). Values are the message associated to the keys, and may include interpolation string starting with ‘%(KEY-’ where ‘KEY’ will be replaced by the associated key once the message has been translated. This allows predictable/translatable message and avoid args conflict if used for several keys.

  • msgargs: dictionary of substitutions to be inserted in error messages once translated (only if msgargs is given)

  • i18nvalues: list of keys in msgargs whose value should be translated

Translation will be done in-place by calling translate().


class cubicweb.Binary(buf=b'')[source]#

class to hold binary data. Use BytesIO to prevent use of unicode data

class cubicweb.CubicWebEventManager[source]#

simple event / callback manager.

Typical usage to register a callback:

>>> from cubicweb import CW_EVENT_MANAGER
>>> CW_EVENT_MANAGER.bind('after-registry-reload', mycallback)

Typical usage to emit an event:

>>> from cubicweb import CW_EVENT_MANAGER
>>> CW_EVENT_MANAGER.emit('after-registry-reload')

emit() accepts an additional context parameter that will be passed to the callback if specified (and only in that case)

cubicweb.onevent(event, *args, **kwargs)[source]#

decorator to ease event / callback binding

>>> from cubicweb import onevent
>>> @onevent('before-registry-reload')
... def mycallback():
...     print 'hello'
cubicweb.validation_error(entity, errors, substitutions=None, i18nvalues=None)[source]#

easy way to retrieve a cubicweb.ValidationError for an entity or eid.

You may also have 2-tuple as error keys, yams.role_name() will be called automatically for them.

Messages in errors should not be translated yet, though marked for internationalization. You may give an additional substition dictionary that will be used for interpolation after the translation.