Hello everybody,

It's about brainstorming on an elegant solution. I previously posted this
question on the Flask mailing list, and I got advised to post it on
SQLAlchemy list... which make more sense I admit. So here is my issue:

I have N different classes:

class Comment(Models):
  author_id = Integer
  comment = String
  creation_date = Date

class Picture(Models):
  author_id = Integer
  image = File
  creation_date = Date
...

now let say, I have a "follow" feature, allowing a user X to get updates
when Y (the user followed by X) does something (creepy...).

So far I came up with something like that:

class FeedItem(Model)
  table = String
  key = Integer
  creation_date = Date

  def url(self):
    #get object by querying self.table with self.key
    object = self.get_an_object(table=self.table, key=self.key)
    return object.view_url

and then add this property to Comment and Picture classes:

  @property
  def view_url(self):
    return url_for('view_function_name', self.id)

- What would be your way of dealing with this kind of "open/generic"
relationship items?

- How would you manage automatic deletion of a FeedItem when the object it
points to get destroyed? (I'm thinking attaching function on delete event
to classes)

- Would you create as many FeedItem per follower, or use a Table to link
them to followers, therefore deleting a FeedItem would automatically delete
the relation record from the Table.?

Thank you,

-- 
Brice

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to