Exemplo n.º 1
0
class EPytisHelpSpecItems(Base_LogSQLTable):
    """Help texts for specification items, such as fields, bindings, actions."""
    name = 'e_pytis_help_spec_items'
    fields = (
        sql.PrimaryColumn('item_id', pytis.data.Serial()),
        sql.Column('spec_name',
                   pytis.data.String(not_null=True),
                   references=sql.a(sql.r.EPytisHelpSpec.spec_name,
                                    onupdate='CASCADE',
                                    ondelete='CASCADE')),
        sql.Column(
            'kind',
            pytis.data.String(not_null=True),
            check="kind in ('field', 'profile', 'binding', 'action', 'proc')"),
        sql.Column('identifier', pytis.data.String(not_null=True)),
        sql.Column('content', pytis.data.String(not_null=False)),
        sql.Column('changed',
                   pytis.data.Boolean(not_null=True),
                   doc="True when the content was edited by hand.",
                   default=False),
        sql.Column('removed',
                   pytis.data.Boolean(not_null=True),
                   doc="False when the item still exists in specification.",
                   default=False),
    )
    inherits = (XChanges, )
    unique = ((
        'spec_name',
        'kind',
        'identifier',
    ), )
    depends_on = ()
    access_rights = default_access_rights.value(globals())
Exemplo n.º 2
0
class EPytisCryptoKeys(Base_LogSQLTable):
    """Table of encryption keys of users for defined encryption areas."""
    name = 'e_pytis_crypto_keys'
    schemas = pytis_schemas.value(globals())
    fields = (
        sql.PrimaryColumn('key_id', pytis.data.Serial()),
        sql.Column('name',
                   pytis.data.String(not_null=True),
                   label=_("Šifrovací oblast"),
                   references=sql.a(sql.r.CPytisCryptoNames.name,
                                    onupdate='CASCADE')),
        sql.Column('username',
                   pytis.data.String(not_null=True),
                   label=_("Uživatel"),
                   doc="Arbitrary user identifier."),
        sql.Column('key', pytis.data.Binary(not_null=True)),
        sql.Column(
            'fresh',
            pytis.data.Boolean(not_null=True),
            label=_("Nový"),
            doc=
            "Flag indicating the key is encrypted by a non-login password. ",
            default=False),
    )
    inherits = (XChanges, )
    unique = ((
        'name',
        'username',
    ), )
    depends_on = (CPytisCryptoNames, )
    access_rights = default_access_rights.value(globals())
Exemplo n.º 3
0
class EPytisHelpPagesAttachments(Base_LogSQLTable):
    """Attachments for help texts (images etc.)"""
    name = 'e_pytis_help_pages_attachments'
    fields = (
        sql.PrimaryColumn('file_id', pytis.data.Serial()),
        sql.Column('page_id',
                   pytis.data.Integer(not_null=True),
                   references=sql.a(sql.r.EPytisHelpPages.page_id,
                                    ondelete='CASCADE')),
        sql.Column('file_name', pytis.data.String(not_null=True)),
        sql.Column('byte_size', pytis.data.Integer(not_null=True)),
        sql.Column('width', pytis.data.Integer(not_null=False)),
        sql.Column('height', pytis.data.Integer(not_null=False)),
        sql.Column('resized_width', pytis.data.Integer(not_null=False)),
        sql.Column('resized_height', pytis.data.Integer(not_null=False)),
        sql.Column('thumbnail_width', pytis.data.Integer(not_null=False)),
        sql.Column('thumbnail_height', pytis.data.Integer(not_null=False)),
        sql.Column('file', pytis.data.Binary(not_null=True)),
        sql.Column('resized', pytis.data.Binary(not_null=False)),
        sql.Column('thumbnail', pytis.data.Binary(not_null=False)),
    )
    inherits = (XChanges, )
    unique = ((
        'page_id',
        'file_name',
    ), )
    depends_on = (EPytisHelpPages, )
    access_rights = default_access_rights.value(globals())
Exemplo n.º 4
0
Arquivo: demo.py Projeto: cerha/pytis
class Indexed(sql.SQLTable):
    name = 'indexed'
    fields = (sql.Column('x', pytis.data.LTree(), index=dict(method='gist')),
              sql.Column('y', pytis.data.LTree()),
              sql.Column('z', pytis.data.LTree()),
              )
    index_columns = (('x', 'y',),
                     sql.a('x', 'y', 'z', method='gist'),)
Exemplo n.º 5
0
Arquivo: demo.py Projeto: cerha/pytis
class ReferencingTable(sql.SQLTable):
    name = 'referencing_table'
    fields = (sql.PrimaryColumn('id', pytis.data.Serial()),
              sql.Column('name', pytis.data.String()),
              sql.Column('action', pytis.data.String()),
              )
    foreign_keys = (sql.a(('name', 'action',), (sql.r.LogTable.table_name, sql.r.LogTable.action,),
                          onupdate='cascade', ondelete='cascade'),)
Exemplo n.º 6
0
class TChangesDetail(sql.SQLTable):
    """Detail information about database changes."""
    name = 't_changes_detail'
    schemas = (('public',),)
    fields = (sql.Column('id', pytis.data.Integer(not_null=True), index=True,
                         references=sql.a(sql.r.TChanges.id, onupdate='CASCADE',
                                          ondelete='CASCADE')),
              sql.Column('detail', pytis.data.String(not_null=True)),
              )
    with_oids = True
    depends_on = (TChanges,)
    access_rights = default_access_rights.value(globals())
Exemplo n.º 7
0
class CmsMenuStructure(sql.SQLTable):
    """Language independent menu structure."""
    name = '_cms_menu_structure'
    schemas = cms_schemas.value(globals())
    external = True
    fields = (
        sql.PrimaryColumn('menu_item_id', pytis.data.Serial()),
        sql.Column(
            'identifier',
            pytis.data.String(maxlen=32, not_null=True),
        ),
        sql.Column(
            'parent',
            pytis.data.Integer(not_null=False),
            references=sql.a(sql.r.CmsMenuStructure.menu_item_id),
        ),
        sql.Column(
            'mod_id',
            pytis.data.Integer(not_null=False),
            references=sql.a(sql.r.CmsModules.mod_id),
        ),
        sql.Column('ord', pytis.data.Integer(not_null=True)),
        sql.Column('tree_order', pytis.data.LTree(not_null=False)),
    )
    index_columns = (
        sql.Arguments('identifier', unique=True),
        sql.Arguments('ord',
                      sqlalchemy.literal_column("coalesce(parent, 0)"),
                      unique=True),
        (
            'parent',
            'ord',
        ),
    )

    depends_on = (CmsModules, )
    access_rights = cms_rights.value(globals())
Exemplo n.º 8
0
class EPytisHelpMenu(Base_LogSQLTable):
    """Texts for help pages."""
    name = 'e_pytis_help_menu'
    fields = (sql.PrimaryColumn('fullname', pytis.data.String(not_null=False),
                                references=sql.a(sql.r.CPytisMenuActions.fullname,
                                                 onupdate='CASCADE', ondelete='CASCADE')),
              sql.Column('content', pytis.data.String(not_null=False)),
              sql.Column('changed', pytis.data.Boolean(not_null=True),
                         doc="True when the content was edited by hand.", default=False),
              sql.Column('removed', pytis.data.Boolean(not_null=True),
                         doc="False when the item still exists in menu.", default=False),
              )
    inherits = (XChanges,)
    with_oids = True
    depends_on = (EPytisMenu,)
    access_rights = default_access_rights.value(globals())
Exemplo n.º 9
0
class Bar(sql.SQLTable):
    """Bar table."""
    name = 'bar'
    schemas = ((
        Private,
        'public',
    ), )
    fields = (
        sql.PrimaryColumn('id', pytis.data.Serial()),
        sql.Column('foo_id',
                   pytis.data.Integer(),
                   references=sql.a(sql.r.Foo.id, onupdate='CASCADE')),
        sql.Column('description', pytis.data.String()),
    )
    init_columns = (
        'foo_id',
        'description',
    )
    init_values = ((1, 'some text'), )
    depends_on = (Foo2, )

    def on_delete(self):
        return ()

    def on_insert_also(self):
        Foo2 = sql.t.Foo2
        n_column = sqlalchemy.literal_column('1').label('n')
        return (
            Foo2.insert().values(
                n=sqlalchemy.literal_column('new.id'),
                foo=sqlalchemy.literal_column('new.description')),
            sql.InsertFromSelect(Foo2, sqlalchemy.select([n_column])),
            "select 42",
        )

    owner = 'pytis'
    access_rights = ((
        'ALL',
        True,
    ), )
Exemplo n.º 10
0
Arquivo: demo.py Projeto: cerha/pytis
 def index_columns(self):
     y = sqlalchemy.func.coalesce(sql.c.FunctionallyIndexed.y,
                                  sqlalchemy.literal_column('-1', type_=sqlalchemy.Integer()))
     return (sql.a('x', y, unique=True),)
Exemplo n.º 11
0
 def index_columns(self):
     y = sqlalchemy.func.coalesce(sql.c.FunctionallyIndexed.y,
                                  sqlalchemy.literal_column('-1', type_=sqlalchemy.Integer()))
     return (sql.a('x', y, unique=True),)