예제 #1
0
파일: source.py 프로젝트: AtomLaw/Ally-Py
'''
Created on Mar 5, 2012

@package: internationalization
@copyright: 2011 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for source API.
'''

from .metadata_internationalization import meta
from ..api.source import Source, TYPE_PYTHON, TYPE_JAVA_SCRIPT, TYPE_HTML
from .file import File
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.schema import Table, Column, ForeignKey
from sqlalchemy.types import Enum

# --------------------------------------------------------------------

table = Table('inter_source', meta,
              Column('fk_file_id', ForeignKey(File.Id), primary_key=True, key='Id'),
              Column('type', Enum(TYPE_PYTHON, TYPE_JAVA_SCRIPT, TYPE_HTML), nullable=False, key='Type'),
              mysql_engine='InnoDB'
              )

Source = mapperModel(Source, table, inherits=File)
예제 #2
0
'''
Created on Aug 25, 2011

@package: ally core sql alchemy
@copyright: 2012 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for article type API.
'''

from . import meta
from ..api.article_type import ArticleType
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.schema import Table, Column
from sqlalchemy.types import String, Integer

# --------------------------------------------------------------------

table = Table(
    'article_type', meta, Column('id', Integer, primary_key=True, key='Id'),
    Column('name', String(255), nullable=False, unique=True, key='Name'))

ArticleType = mapperModel(ArticleType, table)
예제 #3
0
@package: internationalization
@copyright: 2011 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for source API.
'''

from .metadata_internationalization import meta
from ..api.source import Source, TYPE_PYTHON, TYPE_JAVA_SCRIPT, TYPE_HTML
from .file import File
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.schema import Table, Column, ForeignKey
from sqlalchemy.types import Enum

# --------------------------------------------------------------------

table = Table('inter_source',
              meta,
              Column('fk_file_id',
                     ForeignKey(File.Id),
                     primary_key=True,
                     key='Id'),
              Column('type',
                     Enum(TYPE_PYTHON, TYPE_JAVA_SCRIPT, TYPE_HTML),
                     nullable=False,
                     key='Type'),
              mysql_engine='InnoDB')

Source = mapperModel(Source, table, inherits=File)
예제 #4
0
                     ForeignKey(Source.Id, ondelete='RESTRICT'),
                     key='Source'),
              Column('singular',
                     VARCHAR(255, charset='utf8'),
                     nullable=False,
                     key='Singular'),
              Column('plural_1', VARCHAR(255, charset='utf8'), key='plural1'),
              Column('plural_2', VARCHAR(255, charset='utf8'), key='plural2'),
              Column('plural_3', VARCHAR(255, charset='utf8'), key='plural3'),
              Column('plural_4', VARCHAR(255, charset='utf8'), key='plural4'),
              Column('context', VARCHAR(255, charset='utf8'), key='Context'),
              Column('line_number', INTEGER(unsigned=True), key='LineNumber'),
              Column('comments', String(255), key='Comments'),
              mysql_engine='InnoDB')

Message = mapperModel(Message, table)

# --------------------------------------------------------------------


def _onLoadMessage(message):
    '''
    Called when a message is loaded.
    '''
    assert isinstance(message, Message), 'Invalid message %s' % message
    plurals = [
        plural for plural in (getattr(message, 'plural%s' % k)
                              for k in range(1, 5)) if plural is not None
    ]
    if plurals: message.Plural = plurals
예제 #5
0
class MetaInfoMapped(Base, MetaInfo):

    def validate(self):
        o sa fie un singur media data service archive care foloseste file systzem:
            salveaza fisierul local in pathul cunoscut
            notifica data handlerurile de noul fisier dand si locatia fisireului in file system.
        o sa fie un singur thumbnail service unde faci upload la thumbnail si care se ocupa de resizing foloseste file systzem
        fara sa foloseasca un CDM si face resizing on demand bazat pe o lista cunoscuta de resizing. o sa fie un URL
        atasat de meta data ptr thumb si cat se cere thumbu o sa se specifice thumb size, eventual de facut o entitate
        pentru thumb care sa aiba un id unique si sa poate fi folosti ca referinta la upload, asta pentru cazul in care
        folosesti acelasi thumb pentru mai multe meta data si inclusiv daca se face sql pentru selectarea unui thumb
        tot merita, deci ideea ii sa folosim REST aproach si sa nu complicam lucrurile cu tot felu de procese.

        Ideea i ca daca folosim CDM ii complicat procseul si atunci ii mai usor ca serviciul the data si thumbs sa lucreze
        direct cu file system, ele putand fi distrbuite daca ii cazul sau facute implementari pe baza la altfel de
        structuri.



        de facut validatra astfel incat sa nu poti insera meta info pentru alte meta data types, tre facut cu
        declarative base
        de continuat cu image media si dupa aia de facut resize

table = Table('archive_image_info', meta,
              Column('fk_meta_info_id', ForeignKey(MetaInfo.Id), primary_key=True, key='Id'),
              Column('caption', String(255), nullable=False, key='Caption'),
              mysql_engine='InnoDB', mysql_charset='utf8')

ImageInfo = mapperModel(ImageInfo, table, exclude=['MetaData'], inherits=MetaInfo)
validateManaged(ImageInfo.MetaData)
예제 #6
0
'''
Created on Aug 23, 2011

@package superdesk
@copyright 2011 Sourcefabric o.p.s.
@license http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for language API.
'''

from superdesk.language.api.language import LanguageEntity
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.dialects.mysql.base import INTEGER
from sqlalchemy.schema import Table, Column
from sqlalchemy.types import String
from superdesk.meta.metadata_superdesk import meta

# --------------------------------------------------------------------

table = Table('language', meta,
              Column('id', INTEGER(unsigned=True), primary_key=True, key='Id'),
              Column('code', String(20), nullable=False, unique=True, key='Code'),
              mysql_engine='InnoDB', mysql_charset='utf8')

LanguageEntity = mapperModel(LanguageEntity, table)
예제 #7
0
"""
Created on Mar 30, 2012

@package: simple plugin sample
@copyright: 2011 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Mapping for the user model.
"""

from ally.support.sqlalchemy.mapper import mapperModel
from sample_plugin.api.user import User
from sample_plugin.meta import meta
from sqlalchemy.schema import Table, Column
from sqlalchemy.types import String, Integer

# --------------------------------------------------------------------

table = Table(
    "sample_user",
    meta,
    Column("id", Integer, primary_key=True, key="Id"),
    Column("name", String(20), nullable=False, key="Name"),
)

# map User entity to defined table (above)
User = mapperModel(User, table)
예제 #8
0
@package: superdesk media archive
@copyright: 2012 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for media meta info API.
'''

from ..api.meta_info import MetaInfo
from .meta_data import MetaDataMapped
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.dialects.mysql.base import INTEGER
from sqlalchemy.schema import Table, Column, ForeignKey
from sqlalchemy.types import String
from superdesk.language.meta.language import LanguageEntity
from superdesk.meta.metadata_superdesk import meta

# --------------------------------------------------------------------

table = Table('archive_meta_info', meta,
              Column('id', INTEGER(unsigned=True), primary_key=True, key='Id'),
              Column('fk_metadata_id', ForeignKey(MetaDataMapped.Id), nullable=False, key='MetaData'),
              Column('fk_language_id', ForeignKey(LanguageEntity.Id), nullable=False, key='Language'),
              Column('title', String(255), nullable=False, key='Title'),
              Column('keywords', String(255), key='Keywords'),
              Column('description', String(255), key='Description'),
              mysql_engine='InnoDB', mysql_charset='utf8')

MetaInfo = mapperModel(MetaInfo, table)
예제 #9
0
'''
Created on Mar 30, 2012

@package: simple plugin sample
@copyright: 2011 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Mapping for the user model.
'''

from ally.support.sqlalchemy.mapper import mapperModel
from sample_plugin.api.user import User
from sample_plugin.meta import meta
from sqlalchemy.schema import Table, Column
from sqlalchemy.types import String, Integer

# --------------------------------------------------------------------

table = Table('sample_user', meta,
              Column('id', Integer, primary_key=True, key='Id'),
              Column('name', String(20), nullable=False, key='Name'))

# map User entity to defined table (above)
User = mapperModel(User, table)
예제 #10
0
@package: internationalization
@copyright: 2011 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for source API.
'''

from ..api.file import File
from .metadata_internationalization import meta
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.dialects.mysql.base import INTEGER
from sqlalchemy.schema import Table, Column, UniqueConstraint
from sqlalchemy.types import String, DateTime

# --------------------------------------------------------------------

component = Column('component', String(255), nullable=True, key='Component')
plugin = Column('plugin', String(255), nullable=True, key='Plugin')
path = Column('path', String(255), nullable=False, key='Path')

table = Table('inter_file', meta,
              Column('id', INTEGER(unsigned=True), primary_key=True, key='Id'),
              component, plugin, path,
              Column('last_modified', DateTime, nullable=False, key='LastModified'),
              UniqueConstraint(component, plugin, path, name='component_plugin_path_UNIQUE'),
              mysql_engine='InnoDB'
              )

File = mapperModel(File, table)
예제 #11
0
파일: message.py 프로젝트: AtomLaw/Ally-Py
table = Table('inter_message', meta,
              Column('id', INTEGER(unsigned=True), primary_key=True, key='Id'),
              Column('fk_source_id', ForeignKey(Source.Id, ondelete='RESTRICT'), key='Source'),
              Column('singular', VARCHAR(255, charset='utf8'), nullable=False, key='Singular'),
              Column('plural_1', VARCHAR(255, charset='utf8'), key='plural1'),
              Column('plural_2', VARCHAR(255, charset='utf8'), key='plural2'),
              Column('plural_3', VARCHAR(255, charset='utf8'), key='plural3'),
              Column('plural_4', VARCHAR(255, charset='utf8'), key='plural4'),
              Column('context', VARCHAR(255, charset='utf8'), key='Context'),
              Column('line_number', INTEGER(unsigned=True), key='LineNumber'),
              Column('comments', String(255), key='Comments'),
              mysql_engine='InnoDB'
              )

Message = mapperModel(Message, table)

# --------------------------------------------------------------------

def _onLoadMessage(message):
    '''
    Called when a message is loaded.
    '''
    assert isinstance(message, Message), 'Invalid message %s' % message
    plurals = [plural for plural in (getattr(message, 'plural%s' % k) for k in range(1, 5)) if plural is not None]
    if plurals: message.Plural = plurals

def _onPersistMessage(message):
    '''
    Called when a message is persisted.
    '''
예제 #12
0
'''
Created on Aug 25, 2011

@package: ally core sql alchemy
@copyright: 2012 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for article API.
'''

from . import meta
from ..api.article import Article
from .article_type import ArticleType
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.schema import Table, Column, ForeignKey
from sqlalchemy.types import String, Integer

# --------------------------------------------------------------------

table = Table('article', meta,
              Column('id', Integer, primary_key=True, key='Id'),
              Column('fk_article_type_id', ForeignKey(ArticleType.Id), nullable=False, key='Type'),
              Column('name', String(255), nullable=False, key='Name'))

Article = mapperModel(Article, table)
예제 #13
0
'''
Created on Aug 25, 2011

@package: ally core sql alchemy
@copyright: 2012 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for article type API.
'''

from . import meta
from ..api.article_type import ArticleType
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.schema import Table, Column
from sqlalchemy.types import String, Integer

# --------------------------------------------------------------------

table = Table('article_type', meta,
              Column('id', Integer, primary_key=True, key='Id'),
              Column('name', String(255), nullable=False, unique=True, key='Name'))

ArticleType = mapperModel(ArticleType, table)
예제 #14
0
@package superdesk
@copyright 2011 Sourcefabric o.p.s.
@license http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Contains the SQL alchemy meta for language API.
'''

from superdesk.language.api.language import LanguageEntity
from ally.support.sqlalchemy.mapper import mapperModel
from sqlalchemy.dialects.mysql.base import INTEGER
from sqlalchemy.schema import Table, Column
from sqlalchemy.types import String
from superdesk.meta.metadata_superdesk import meta

# --------------------------------------------------------------------

table = Table('language',
              meta,
              Column('id', INTEGER(unsigned=True), primary_key=True, key='Id'),
              Column('code',
                     String(20),
                     nullable=False,
                     unique=True,
                     key='Code'),
              mysql_engine='InnoDB',
              mysql_charset='utf8')

LanguageEntity = mapperModel(LanguageEntity, table)