Beispiel #1
0
'''
SQLAlchemy models for Authentications
'''
import enum
from datetime import datetime

from sqlalchemy.orm import relationship
from sqlalchemy import Column, Integer, String, ForeignKey, Boolean, DateTime

from odm.types import IPAddressType, UUIDType, JSONType

from lux.extensions import odm
from lux.extensions.rest import UserMixin


Model = odm.model_base('auth')


users_groups = Model.create_table(
    'users_groups',
    Column('user_id', Integer, ForeignKey('user.id')),
    Column('group_id', Integer, ForeignKey('group.id')),
)


groups_permissions = Model.create_table(
    'groups_permissions',
    Column('group_id', Integer, ForeignKey('group.id')),
    Column('permission_id', Integer, ForeignKey('permission.id'))
)
Beispiel #2
0
class Extension(LuxExtension):
    def api_sections(self, app):
        yield ownership.owned_model(app,
                                    ProjectCrud(),
                                    'name',
                                    cast_id=cast_int)
        routes = api_info_routes(app)
        routes['version'] = self.get_version
        routes['python'] = python_packages

    def get_version(self, request):
        return {'version': '0.1.0'}


Model = odm.model_base('orgtest')


class Project(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(32), nullable=False)
    subject = Column(String(250))
    deadline = Column(String(250))
    outcome = Column(String(250))
    created = Column(DateTime, default=datetime.utcnow)


class CreateProject(forms.Form):
    name = forms.SlugField(min_length=2,
                           max_length=32,
                           validator=ownership.UniqueField('projects'))
Beispiel #3
0
            request.cache.del_items = []
        request.cache.new_items.extend(odm_json(request, session.new))
        request.cache.old_items.extend(odm_json(request, session.dirty))
        request.cache.del_items.extend(odm_json(request, session.deleted))

    def on_before_commit(self, app, session):
        request = session.request
        if not request:
            return
        if request.cache.new_items_before_commit is None:
            request.cache.new_items_before_commit = []
        request.cache.new_items_before_commit.extend(
            odm_json(request, session.new))


Model = odm.model_base('odmtest')


# ODM Models
class Person(Model):
    id = Column(Integer, primary_key=True)
    username = Column(String(250), unique=True)
    name = Column(String(250))


class Task(Model):
    id = Column(Integer, primary_key=True)
    subject = Column(String(250))
    done = Column(Boolean, default=False)
    created = Column(DateTime, default=datetime.utcnow)
    enum_field = Column(ChoiceType(TestEnum, impl=Integer),
Beispiel #4
0
        request.cache.new_items.extend(odm_json(request, session.new))
        request.cache.old_items.extend(odm_json(request, session.dirty))
        request.cache.del_items.extend(odm_json(request, session.deleted))

    def on_before_commit(self, app, session):
        request = session.request
        if not request:
            return
        if request.cache.new_items_before_commit is None:
            request.cache.new_items_before_commit = []
        request.cache.new_items_before_commit.extend(
            odm_json(request, session.new)
        )


Model = odm.model_base('odmtest')


# ODM Models
class Person(Model):
    id = Column(Integer, primary_key=True)
    username = Column(String(250), unique=True)
    name = Column(String(250))


class Task(Model):
    id = Column(Integer, primary_key=True)
    subject = Column(String(250))
    done = Column(Boolean, default=False)
    created = Column(DateTime, default=datetime.utcnow)
    enum_field = Column(ChoiceType(TestEnum, impl=Integer),
Beispiel #5
0
'''
SQLAlchemy models for Authentications
'''
from datetime import datetime

from sqlalchemy.orm import relationship, backref
from sqlalchemy import Column, Integer, String, ForeignKey, Boolean, DateTime

from odm import declared_attr
from odm.types import IPAddressType, UUIDType, JSONType

from lux.extensions import odm
from lux.core import UserMixin

Model = odm.model_base('auth')

users_groups = Model.create_table(
    'users_groups',
    Column('user_id', Integer, ForeignKey('user.id')),
    Column('group_id', Integer, ForeignKey('group.id')),
)

groups_permissions = Model.create_table(
    'groups_permissions', Column('group_id', Integer, ForeignKey('group.id')),
    Column('permission_id', Integer, ForeignKey('permission.id')))


class User(Model, UserMixin):
    id = Column(Integer, primary_key=True)
    username = Column(String(50), unique=True)
    first_name = Column(String(30))
Beispiel #6
0
"""Database modles for storuing lightstream metadata
"""
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.orm import relationship

from lux.extensions import odm
from lux.utils.text import engine

from odm.types import JSONType, UUIDType


Model = odm.model_base('applications')


class AppDomain(Model):
    id = Column(UUIDType(binary=False), primary_key=True)
    """Unique ID of application"""
    name = Column(String(120), nullable=False, unique=True)
    """Unique name of application"""
    domain = Column(String(120), nullable=True, unique=True)
    """Unique domain name of this application"""
    secret = Column(String(64), nullable=False)
    """Secret token for root control of application"""
    config = Column(JSONType)

    def __str__(self):
        return self.name


class AppPlugin:
    """Application plugins are always owned by the master application
Beispiel #7
0
class Extension(LuxExtension):

    def api_sections(self, app):
        yield ownership.owned_model(
            app, ProjectCrud(), 'name', cast_id=cast_int
        )
        routes = api_info_routes(app)
        routes['version'] = self.get_version
        routes['python'] = python_packages

    def get_version(self, request):
        return {'version': '0.1.0'}


Model = odm.model_base('orgtest')


class Project(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(32), nullable=False)
    subject = Column(String(250))
    deadline = Column(String(250))
    outcome = Column(String(250))
    created = Column(DateTime, default=datetime.utcnow)


class CreateProject(forms.Form):
    name = forms.SlugField(min_length=2, max_length=32,
                           validator=ownership.UniqueField('projects'))
    subject = forms.CharField(max_length=250, required=False)
Beispiel #8
0
"""Database modles for storuing lightstream metadata
"""
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.orm import relationship

from lux.extensions import odm
from lux.utils.text import engine

from odm.types import JSONType, UUIDType

Model = odm.model_base('applications')


class AppDomain(Model):
    id = Column(UUIDType(binary=False), primary_key=True)
    """Unique ID of application"""
    name = Column(String(120), nullable=False, unique=True)
    """Unique name of application"""
    domain = Column(String(120), nullable=True, unique=True)
    """Unique domain name of this application"""
    secret = Column(String(64), nullable=False)
    """Secret token for root control of application"""
    config = Column(JSONType)

    def __str__(self):
        return self.name


class AppPlugin:
    """Application plugins are always owned by the master application
    """