Library info as json

This commit is contained in:
Ruud committed 2012-03-12 21:43:34 +01:00
1 parent eceaf465f0
commit 63225f7e5c
3 files changed
+16 -11

No files matched your search

+14 -3
View File
@@ -1,10 +1,12 @@
from couchpotato.core.helpers.encoding import toUnicode
from elixir.entity import Entity
from elixir.fields import Field
from elixir.options import options_defaults, using_options
from elixir.relationships import ManyToMany, OneToMany, ManyToOne
from libs.elixir.relationships import OneToOne
from sqlalchemy.types import Integer, Unicode, UnicodeText, Boolean, Float, \
String
String, TypeDecorator
import json
options_defaults["shortnames"] = True
@@ -16,6 +18,16 @@ options_defaults["shortnames"] = True
__session__ = None
class JsonType(TypeDecorator):
impl = UnicodeText
def process_bind_param(self, value, dialect):
return toUnicode(json.dumps(value))
def process_result_value(self, value, dialect):
return json.loads(value)
class Movie(Entity):
"""Movie Resource a movie could have multiple releases
The files belonging to the movie object are global for the whole movie
@@ -35,11 +47,10 @@ class Library(Entity):
year = Field(Integer)
identifier = Field(String(20), index = True)
rating = Field(Float)
plot = Field(UnicodeText)
tagline = Field(UnicodeText(255))
info = Field(UnicodeText)
info = Field(JsonType)
status = ManyToOne('Status')
movies = OneToMany('Movie')