On Jul 8, 2010, at 5:33 PM, Fernando wrote: > hello, > > I'm trying to auto-fill a "slug" column based on "title" after > creation. Since the "slug" column is unique i need to check other > records to avoid duplication. > > I've tried a couple of things with sessionextension but with no avail. > > Has anyone done smth similar? Any ideas or directions?
populate the "slug" field inside the __init__ method of your object. If you'd like duplicates to raise an error, the database will do that for you assuming you have a unique constraint on the column (which you should). If OTOH you'd like the "slug" to have some alternate value in that case, perform a query inside the __init__ method for the existing field. sessionextension is overkill here. -- 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.
