[Grok-dev] megrok.traject

Christian Klinger cklinger at novareto.de
Wed Dec 2 08:07:59 EST 2009


Hi again,

i found a way to get this working.


Base = declarative_base()
class User(Base, grok.Model):
    ...


This works, but i am not sure if it's the right direction?

Is this ok to do this way?

Christian


> Hi,
>
> i currently play a bit with megrok.traject. Does anyone
> knew how i locate the user object in the factory?
>
>
> class SomeTraject(traject.Traject):
>        grok.context(Pgrestraject)
>
>        pattern = 'users/:user_id'
>        model = User
>
>        def factory(self, user_id):
>            session = Session()
>            user = session.query(User).filter(
>                      User.id == int(user_id)).one()
>            return user
>
>        def arguments(user):
>            return dic(user_id=user.id)
>
> I tried it with megrok.traject.locate but this needs an root
> object. I don't know how i can get the root object.
>
> The class User is a sqlalchemy declarative base:
>
> Base = declarative_base()
> class User(Base):
>      ...
>
> Any ideas?
>
> Christian




More information about the Grok-dev mailing list