Hi,
As I ran into the same kind of problem some times ago, you should take a
look at mapper or session extensions.
As an example, you could take a look at MapperExtension and add some
methods like
class MyModelExtension(MapperExtension):
def before_insert(self, mapper, connection, instance):
some kind
of code
def after_insert(self, mapper, connection, instance):
some kind
of code
def after_delete(self, mapper, connection, instance):
some kind
of code
and a Declarative Model like this:
class MyModel(Base):
__tablename__ = 'mymodel_table'
id = Column(Integer, primary_key=True)
slug = Column('type', String(50))
...
__mapper_args__ = {'extension': MyModelExtension()}
Then everything should be OK
Regards,
Laurent
Tcourbon a écrit :
> Hi there !
>
> I'm new to SQLAlchemy (and python actually) and I read through the
> documentation as I'm using SQLAlchemy (and Pylons) to run a database
> driven website. As I come from php, my former ORM of choice was
> doctrine (http://www.doctrine-project.org/). One of the features I
> used to love was "behavior" (http://www.doctrine-project.org/
> documentation/manual/1_1/en/behaviors). In short it's the ability to
> alter query/data/whatever-you-want-here before and after a query is
> executed. For instance, automatic slug generation (which is what I'm
> looking to use/implement currently).
>
> I wonder if their is something similar in SQLALchemy, or if not, if
> their is some hook (let's say something like a preInsert or preUpdate
> method in Table) I could use to customize my model.
>
> Thank,
> Thomas
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---