The keystone.common.sql.core Module

SQL backends for the various services.

class keystone.common.sql.core.Base

Bases: object

get_engine(allow_global_engine=True)

Return a SQLAlchemy engine.

If allow_global_engine is True and an in-memory sqlite connection string is provided by CONF, all backends will share a global sqlalchemy engine.

get_session(autocommit=True, expire_on_commit=False)

Return a SQLAlchemy session.

get_sessionmaker(engine, autocommit=True, expire_on_commit=False)

Return a SQLAlchemy sessionmaker using the given engine.

class keystone.common.sql.core.DictBase

Bases: object

attributes = []
classmethod from_dict(d)
get(key, default=None)
iteritems()

Make the model object behave like a dict.

Includes attributes from joins.

next()
to_dict(include_extra_dict=False)

Returns the model’s attributes as a dictionary.

If include_extra_dict is True, ‘extra’ attributes are literally included in the resulting dictionary twice, for backwards-compatibility with a broken implementation.

update(values)

Make the model object behave like a dict.

class keystone.common.sql.core.JsonBlob(*args, **kwargs)

Bases: sqlalchemy.types.TypeDecorator

impl

alias of Text

process_bind_param(value, dialect)
process_result_value(value, dialect)
class keystone.common.sql.core.MySQLPingListener

Bases: object

Ensures that MySQL connections checked out of the pool are alive.

Borrowed from: http://groups.google.com/group/sqlalchemy/msg/a4ce563d802c929f

Error codes caught: * 2006 MySQL server has gone away * 2013 Lost connection to MySQL server during query * 2014 Commands out of sync; you can’t run this command now * 2045 Can’t open shared memory; no answer from server (%lu) * 2055 Lost connection to MySQL server at ‘%s’, system error: %d

from http://dev.mysql.com/doc/refman/5.6/en/error-messages-client.html

checkout(dbapi_con, con_record, con_proxy)
keystone.common.sql.core.get_global_engine()
keystone.common.sql.core.handle_conflicts(type='object')

Converts IntegrityError into HTTP 409 Conflict.

keystone.common.sql.core.initialize_decorator(init)

Ensure that the length of string field do not exceed the limit.

This decorator check the initialize arguments, to make sure the length of string field do not exceed the length limit, or raise a ‘StringLengthExceeded’ exception.

Use decorator instead of inheritance, because the metaclass will check the __tablename__, primary key columns, etc. at the class definition.

keystone.common.sql.core.set_global_engine(engine)

Previous topic

The keystone.common.serializer Module

Next topic

The keystone.common.sql.legacy Module

This Page