[Grok-dev] spotlight on: megrok.traject

Aroldo Souza-Leite asouzaleite at gmx.de
Mon Jan 25 05:58:42 EST 2010

Hi Martijn,

am I wrong in the expectation that an object of a non-Grok class 
(see attachment) would be instantiated by 'factory' in 
as a result of the request defined in 'pattern' and that this object (or 
some view of it) would
be shown in the response?

If this is what 'megrok.traject' does to a non-Grok model, then I got 
stuck where
think I should implement a view for the non-Grok class 
'SomeForeignModel'. How can I do this?

Perhaps I just didn't get the basic idea of the 'megrok.traject' usage 
for non-Grok classes?



Martijn Faassen wrote:
> Spotlight on...
> megrok.traject is a package that allows a different way to publish your 
> models than the traversal that is most commonly used in Zope 
> applications. With megrok.traject you can define explicitly what kind of 
> URLs you want to publish your models on, instead of having to construct 
> an object hierarchy.
> A model can be anything that you want to have views for, and doesn't 
> need to be a persistent ``grok.Model``. In fact megrok.traject is most 
> suitable for objects that are not stored in the ZODB, as the ZODB makes 
> traversal easy.
> What kind of models could you publish with megrok.traject then? It
> could be just Python objects you design yourself. In this case you can 
> use ``traject.Model``. You tell it under what URL pattern it should 
> appear and how it is to be constructed, and you're done. 
> ``traject.Model`` is very lightweight: it's just a ``grok.Context`` that 
> can be hooked up by a "traject pattern".
> Alternatively you may want to treat your models even more lightly: you 
> may wish to hook up models that are defined by a package that is not 
> under your control at all. You could have for instance an ORM such as 
> SQAlchemy define the models in an entirely different package that knows 
> nothing about how these models should be presented on the web in your 
> application. You can then use ``traject.Traject`` to associate such 
> models with a URL pattern in your application.
> You can look at the megrok.traject documentation for more information:
> http://pypi.python.org/pypi/megrok.traject
> The low-level implementation is a reusable library called ``traject``, 
> and its documentation can give you more details:
> http://pypi.python.org/pypi/traject
> If you still don't understand why megrok.traject would be useful for 
> *you*, don't worry. Grok's traversal method of publishing objects isn't 
> going anywhere, and megrok.traject is just an option. If you have 
> questions, we'd very much like to hear them on grok-dev however, so that 
> we can improve megrok.traject and its documentation.
> Volunteers who would want to write a tutorial oriented towards beginners 
> that uses megrok.traject would also be very welcome!
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: app.py
Type: text/x-python
Size: 1570 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20100125/507a3864/attachment.py 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: app.txt
Url: http://mail.zope.org/pipermail/grok-dev/attachments/20100125/507a3864/attachment.txt 

More information about the Grok-dev mailing list