Stop using pylons.h.
[zzz-floof.git] / floof / model / search.py
1 from elixir import *
2 # from users import User
3
4
5 class SavedSearch(Entity):
6 string = Field(Unicode) # I tried calling this query, but it broke elixir
7 author = ManyToOne('User')
8 fork = ManyToOne("SavedSearch")
9
10 def __unicode__(self):
11 return self.string
12
13
14
15 class GalleryWidget(Entity):
16 page = ManyToOne('UserPage')
17 search = ManyToOne(SavedSearch)
18
19 # NOTE: no longer needed now that we have pages, I guess.
20 # displayer = ManyToOne('User') # determines whose page should it should show up on
21 # # Could be no-ones, if it's just a template.
22
23 # Needs some fields for position on your page
24
25 @property
26 def string(self):
27 return self.search
28
29 @string.setter
30 def string(self, value):
31 # TODO: should we delete the possibly orphaned saved search?
32 # if not self.displayer:
33 # # TODO: may have to refactor this into an init if the key ordering is inconvenienc
34 # raise "Oh no! This gallery needs a displayer to set on the saved search."
35
36 self.search = SavedSearch(author=getattr(self,"author",None), string=value)