You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
1.5 KiB

from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy import create_engine
from sqlalchemy.schema import ThreadLocalMetaData
from elixir import *
# We would like to be able to create this schema in a specific database at
# will, so we can test it easily.
# Make elixir not bind to any session to make this possible.
#
# http://elixir.ematia.de/trac/wiki/Recipes/MultipleDatabasesOneMetadata
__session__ = None
class Resource(Entity):
"""Represents a resource of movies. This recources can be online or
offline."""
name = Field(UnicodeString(255))
path = Field(UnicodeString(255))
releases = OneToMany('Release')
class Release(Entity):
"""Logically groups all files that belong to a certain release, such as
parts of a movie, subtitles, nfo, trailers etc."""
files = OneToMany('File')
mooli_id = Field(Integer)
resource = ManyToOne('Resource')
class File(Entity):
"""File that belongs to a release."""
history = OneToMany('RenameHistory')
path = Field(UnicodeString(255), nullable=False, unique=True)
# Subtitles can have multiple parts, too
part = Field(Integer)
release = ManyToOne('Release')
# Let's remember the size so we know about offline media.
size = Field(Integer, nullable=False)
type = ManyToOne('FileType')
class FileType(Entity):
"""Types could be trailer, subtitle, movie, partial movie etc."""
identifier = Field(String(20), unique=True)
name = Field(UnicodeString(255), nullable=False)
files = OneToMany('File')