Manlio Perillo wrote:
> Michael Bayer ha scritto:
>> On Jan 28, 2008, at 6:03 AM, Manlio Perillo wrote:
>>
>>> Hi.
>>>
>>> In this wiki page:
>>> http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers
>>>
>>> there is a recipe on how to add basic foreign key support to SQLite
>>> using triggers.
>>>
>>> Is it possible to implement this recipe in SQLAlchemy?
>>>
>>> Some time ago I have tried to implement it, by adding support for
>>> triggers in SQLAlchemy (so that they can be automatically
>>> created/dropped) but I have abandoned the project because the  
>>> internals
>>> of SQLAlchemy are unstable.
>>
>> we have ticket 903 http://www.sqlalchemy.org/trac/ticket/903  with a  
>> suggested way we'll be accomplishing this, a generic DDL() construct  
>> that associates with table/metadata creates/drops.  we just haven't  
>> decided on exact API details but comments are welcome.
>>
> 
> Thanks.
> I like the idea of custom events.
> 
> However, instead of having:
> table.events['after-create'].append(run)
> 
> IMHO it is better an higher level:
> table.add_event(phase, event_type, callable, *args, **kwargs)
> 
> Where phase is "create" or "drop" and event_type is "before" or "after".

An updated implementation is up on the trac, give it a whirl if you 
like.  It includes table.append_ddl_listener(event, listener)

Depending on how regular your schema is, it may be possible to 
generically implement the FK-like triggers with the simple templating 
support built-in to the DDL object in the patch.  If not, it should be a 
very simple task with the listener events.  They get called with the 
Table, so you can introspect and do conditional generation based on the 
columns in each individual table...

-j

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to