On Wed, 2011-02-16 at 12:09 -0800, Wyatt Baldwin wrote:
> I would like to move from Pylons 1.0 to Pyramid, but I'm not going to
> be able manage a wholesale port any time soon. So, I'm wondering if it
> would be practical to start using some parts of Pyramid within an
> existing Pylons project.
> 
> In particular, one of the problems I'm having with Pylons is with
> configuration extensibility. I've got something working, but it feels
> clunky and is somewhat confusing. I haven't looked too closely at
> Pyramid, but it seems like its config system makes gathering & merging
> config from various locations a bit simpler.
> 
> Has anyone done anything like this? Would any of the devs be able to
> advise on whether this an idea worth pursuing?

One idea is to use a Pyramid "NotFound
view" 
(http://docs.pylonsproject.org/projects/pyramid/1.0/narr/hooks.html#changing-the-not-found-view)
 which delegates to the existing Pylons application, and port piecemeal.  
Unfortunately we don't have any current example of doing such a thing, but it 
would involve something like this during Pyramid configuration:

class LegacyView(object):
    def __init__(self, app):
        self.app = app # app is the legacy Pylons app

    def __call__(self, request):
        return request.get_response(self.app)

if __name__ == '__main__':
   pylonsapp = ... obtain pylons WSGI application object ...
   legacy_view = LegacyView(pylonsapp)
   config = Configurator()
   config.add_view(context=NotFound, view=legacy_view)
   ... rest of config ...

At that point, whenever Pyramid cannot service a request because the URL
doesn't match anything, it will invoke the Pylons application as a
fallback, which will return things normally.

At that point you can start moving logic incrementally into Pyramid from
the Pylons application until you've ported everything.

- C


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to