[Grok-dev] megrok.traject

Christian Klinger cklinger at novareto.de
Wed Dec 2 08:01:47 EST 2009


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