from opengever.ogds.models.declarative import query_base


UNIT_ID_LENGTH = 30
UNIT_TITLE_LENGTH = 255
GROUP_ID_LENGTH = 255
USER_ID_LENGTH = 255
FIRSTNAME_LENGTH = 255
LASTNAME_LENGTH = 255
EMAIL_LENGTH = 255
GROUP_TITLE_LENGTH = 255


BASE = query_base()
Exemple #2
0

def get_locale():
    try:
        ltool = api.portal.get_tool('portal_languages')
    except CannotGetPortalError:
        return DEFAULT_LOCALE

    language_code = ltool.getPreferredLanguage()
    return language_code.split('-')[0]


Session = named_scoped_session('opengever')

BASE.session = Session
Base = query_base(Session)

make_translatable(options={'locales': SUPPORTED_LOCALES})
sqlalchemy_utils.i18n.get_locale = get_locale


def get_tables(table_names):
    tables = Base.metadata.tables
    return [tables.get(table_name) for table_name in table_names]


def create_session():
    """Returns a new sql session bound to the defined named scope.
    """
    return Session()