Here's a better CascadeOptions implementation: from sets import Set class CascadeOptions(Set): """keeps track of the options sent to relation().cascade""" def __init__(self, arg=""): values = util.Set([c.strip() for c in arg.split(',')]) if "delete-orphan" in values: self.add("delete-orphan") if "delete" in values or self.delete_orphan or "all" in values: self.add("delete") if "save-update" in values or "all" in values: self.add ("save-update") if "merge" in values or "all" in values: self.add("merge") if "expunge" in values or "all" in values: self.add("expunge") for name in ("delete-orphan", "delete", "save-update", "merge", "expunge"): setattr(self, name.replace("-", "_"), name in self) # refresh_expire not really implemented as of yet #self.refresh_expire = "refresh-expire" in values or "all" in values # def __contains__(self, item): # return getattr(self, item.replace("-", "_"), False)
This does the item.replace("-", "_") part once on initialization rather than every time __contains__ is called. It works as long as nothing ever tries to change the options after the object is initialized. ~ Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---