cubicweb

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

Exceptions

Base exceptions

exception cubicweb.ProgrammingError[source]

Bases: exceptions.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

Bases: exceptions.Exception

base class for cubicweb server exception

exception cubicweb.InternalError

Bases: cubicweb._exceptions.CubicWebException

base class for exceptions which should not occur

exception cubicweb.SecurityError

Bases: cubicweb._exceptions.CubicWebException

base class for cubicweb server security exceptions

exception cubicweb.RepositoryError

Bases: cubicweb._exceptions.CubicWebException

base class for repository exceptions

exception cubicweb.SourceException

Bases: cubicweb._exceptions.CubicWebException

base class for source exceptions

exception cubicweb.CubicWebRuntimeError

Bases: cubicweb._exceptions.CubicWebException

base class for runtime exceptions

Repository exceptions

exception cubicweb.ConnectionError

Bases: cubicweb._exceptions.RepositoryError

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

exception cubicweb.AuthenticationError

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

Bases: cubicweb._exceptions.ConnectionError

raised when a bad connection id is given

exception cubicweb.UnknownEid

Bases: cubicweb._exceptions.RepositoryError

the eid is not defined in the system tables

exception cubicweb.UniqueTogetherError(session, **kwargs)

Bases: cubicweb._exceptions.RepositoryError

raised when a unique_together constraint caused an IntegrityError

Security Exceptions

exception cubicweb.Unauthorized

Bases: cubicweb._exceptions.SecurityError

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

exception cubicweb.Forbidden

Bases: cubicweb._exceptions.SecurityError

raised when a user tries to perform a forbidden action

Source exceptions

exception cubicweb.EidNotInSource

Bases: cubicweb._exceptions.SourceException

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

Registry exceptions

exception cubicweb.UnknownProperty

Bases: logilab.common.registry.RegistryException

property found in database but unknown in registry

Query exceptions

exception cubicweb.QueryError

Bases: cubicweb._exceptions.CubicWebRuntimeError

a query try to do something it shouldn’t

exception cubicweb.NotAnEntity

Bases: cubicweb._exceptions.CubicWebRuntimeError

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

exception cubicweb.MultipleResultsError

Bases: cubicweb._exceptions.CubicWebRuntimeError

raised when ResultSet.one() is called on a resultset with multiple rows of multiple columns.

exception cubicweb.NoResultError

Bases: cubicweb._exceptions.CubicWebRuntimeError

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

exception cubicweb.UndoTransactionException(txuuid, errors)

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.
Parameters:
  • txuuid – Unique identifier of the partially undone transaction
  • errors (list) – List of errors occurred during undoing

Misc

exception cubicweb.ConfigurationError

Bases: cubicweb._exceptions.CubicWebException

a misconfiguration error

exception cubicweb.ExecutionError

Bases: exceptions.Exception

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

exception cubicweb.BadCommandUsage

Bases: exceptions.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, msgargs=None, i18nvalues=None)

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().

Utilities

class cubicweb.Binary(buf='')[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.

Table Of Contents

Previous topic

Changelog history

Next topic

cubicweb.appobject