1df10ccc3541a87379c77c3937ab3b91aa4c25cf
[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 uploaded_by = ManyToOne('User')
19
20 def __init__(self, **kwargs):
21 # I wanted to check for the existence of the file, but...
22 # for some reason this FieldStorage object always conditions as falsey.
23 self.hash = save_file("art", kwargs.pop('file'))
24 super(Art, self).__init__(**kwargs)
25 # this is what super is doing, pretty much.
26 # for key, value in kwargs.items():
27 # setattr(self, key, value)
28
29
30
31 def get_path(self):
32 if self.hash:
33 return get_path("art", self.hash)