e78de41f928c118862ed0cae791ebc99400b6b0d
[zzz-floof.git] / floof / model / art.py
1 #
2 # floof/floof/model/art.py
3 #
4 # Copyright (c) 2009 Scribblr
5 #
6
7 from elixir import Entity, Field, Integer, Unicode
8 from elixir import *
9
10 from pylons import config
11
12 from floof.lib.file_storage import get_path, save_file
13
14 class Art(Entity):
15 title = Field(Unicode(120))
16 original_filename = Field(Unicode(120))
17 hash = Field(String)
18
19 def __init__(self, **kwargs):
20 # I wanted to check for the existence of the file, but...
21 # for some reason this FieldStorage object always conditions as falsey.
22 self.hash = save_file("art", kwargs.pop('file'))
23
24
25 super(Art, self).__init__(**kwargs)
26 # this is what super is doing, pretty much.
27 # for key, value in kwargs.items():
28 # setattr(self, key, value)
29
30
31
32 def get_path(self):
33 if self.hash:
34 return get_path("art", self.hash)