On Sat, Feb 05, 2011 at 09:41:00PM -0800, Mike Orr wrote: > Here's the first draft of my Pyramid Migration Guide. ... > Online version: > https://bytebucket.org/sluggo/pyramid-docs/wiki/html/migration.html > Sphinx source: https://bitbucket.org/sluggo/pyramid-docs/src
I've some minor fixes (spelling, ReST syntax); patch attached. > This is part of my Pyramid Supplemental Docs project. It will > eventually be on github and in the Pyramid docs, Yay! > but first I wanted to > get it written. > > Replies to pylons-devel if it's a minor bug report or comment or > Pyramid usage issue, or to pylons-discuss if you think it's important > to all Pylons users. (Thank you, I tend to forget there's more than one list, since my procmail puts everything Pylons-related into one mailbox. To: list trimmed.) Some notes about URL generation methods: * ``elements`` are path segments that will be appended to the URL, separated with slashes. This is more useful when you use traversal, e.g. request.resource_url(some_resource, 'view_name') * It's probably worth mentioning that you can supply a _query argument to route_url, e.g. request.route_url('search', _query={'q': 'search keyword'}) * After mentioning that static_url is not useful with pyramid_sqla, it'd be nice to tell the developer how she can safely generate URLs to static files. (This is documented later in the document, so a link to #static-files would probably be better than repetition.) The section about path attributes could really use some examples. Marius Gedminas -- You've obviously never tried to reverse engineer a chip using an electron microscope. [...] That's like looking at the grains of sand on a beach and trying to map out the coastline of Hawaii. -- Cutie Pi, July 2006
diff -r 8d499153bd9a migration.rst --- a/migration.rst Sat Feb 05 21:03:45 2011 -0800 +++ b/migration.rst Mon Feb 07 15:29:03 2011 +0200 @@ -59,7 +59,7 @@ view, view handler A *view* or *view callable* is a function or method equivalent to a Pylons - controller action A *view handler* is a class containing view methods, so + controller action. A *view handler* is a class containing view methods, so the equivalent of a Pylons controller. Pyramid is more of an "MV" (model-view) framework than an "MVC" (model-view-controller) framework, to avoid unnecessary problems distinguishing controller code from view code in @@ -322,8 +322,8 @@ $ paster pshell development.ini MyApp Some other Paster plugins use the syntax "development.ini#MyApp". This does not -any that are commonly used with Pyramid, but we mention it here in case you -encounter it. ("paster setup-app" uses it.) +include any that are commonly used with Pyramid, but we mention it here in case +you encounter it. ("paster setup-app" uses it.) Obviously it can be kind of annoying to type the application name repeatedly on the command line, especially if it contains uppercase letters. You can change @@ -491,7 +491,7 @@ # name = sa.Column(sa.Unicode(255), nullable=False) Instead of a ``meta`` module to hold SQLAlchemy's housekeeping objects, -`pyramid_sqla`` provides a library to contain them. This allows you to +``pyramid_sqla`` provides a library to contain them. This allows you to structure your models as a single module or a package without a ``meta`` module and without circular imports. The library provides a SQLAlchemy scoped session, a place to store and retrieve engines, and a declarative base. You can use any @@ -776,15 +776,15 @@ info["route"].pattern => the URL pattern of the current route Use custom predicates argument when none of the other predicate args fit - your situation. See - <http://docs.pylonsproject.org/projects/pyramid/1.0/narr/urldispatch.html#custom-route-predicates>` + your situation. See `Custom Route Predicates + <http://docs.pylonsproject.org/projects/pyramid/1.0/narr/urldispatch.html#custom-route-predicates>`_ in the Pyramid manual for examples. You can modify the match dict to affect how the view will see it. For instance, you can look up a model object based on its ID and put the object in the match dict under another key. If the record is not found in the model, you can return False to prevent the route from matching the request; - this will ultimately case HTTPNotFound if no other route or traversal + this will ultimately cause HTTPNotFound if no other route or traversal matches the URL. The difference between doing this and returning HTTPNotFound in the view is that in the latter case the following routes and traversal will never be consulted. That may or may not be an advantage @@ -843,11 +843,10 @@ as an argument.) Pyramid's Request_ object is a subclass of WebOb.Request_ just like -pylons.request is, so it contains all the same attributes in methods like +pylons.request is, so it contains all the same attributes like ``params``, ``GET``, ``POST``, ``headers``, ``method``, ``charset``, ``date``, -``environ``, ``body``, ``body_file``. -so it contains all -attributes and methods. The following are specific to Pyramid. +``environ``, ``body``, ``body_file``. +The following are specific to Pyramid. Special Pyramid attributes and methods -------------------------------------- @@ -1092,7 +1091,7 @@ <html> <head> <title>${self.title()}</title> - <link rel="stylesheet" href="${application_url}/default.css" + <link rel="stylesheet" href="${request.application_url}/default.css" type="text/css" /> </head> <body> @@ -1128,7 +1127,7 @@ not exist, the route will not match the URL and Pyramid will try the next route or traversal. You cannot use any of the URL generation methods with this; instead you can put a literal URL like - "${application_url}/images/logo.png" in your template. + "${request.application_url}/images/logo.png" in your template. Usage::
signature.asc
Description: Digital signature