Changeset 5001
- Timestamp:
- 07/18/08 19:51:41 (6 months ago)
- Files:
-
- trunk/docs/main/RoutesIntegration.rst (modified) (1 diff)
- trunk/docs/main/TG2Philosophy.rst (modified) (3 diffs)
- trunk/docs/main/TGandPyAMF.rst (modified) (1 diff)
- trunk/docs/main/WhatsNew.rst (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docs/main/RoutesIntegration.rst
r4575 r5001 9 9 :depth: 2 10 10 11 TurboGears2 does URL dispatch with a combination of TG1 style object dispatch, and built in Routes integration. By default you don't 12 need to think about Routes at all, because the framework sets up a default route to your RootController, which sees that the action is route, and does object dispatch in the same way that TurboGears 1 did. 11 TurboGears2 does URL dispatch with a combination of TG1 style object dispatch, 12 and built in Routes integration. By default you don't need to think about 13 Routes at all, because the framework sets up a default route to your 14 RootController, which sees that the action is route, and does object 15 dispatch in the same way that TurboGears 1 did. 13 16 14 But if you want to create special routes that overide Object Dispatch, you can easily do that, just by providing your own function to setup the routes map. TurboGears has a setup module, which provides a make_default_route_map function like this :: 17 But if you want to create special routes that overide Object Dispatch, 18 you can easily do that, just by providing your own function to setup the 19 routes map. YOu can update the routes defaults by overriding the setup_routes 20 method of the base_config object in app_cfg.py. 15 21 16 from pylons import config 17 from routes import Mapper 22 The standard setup_routes method looks like this:: 18 23 19 def make_default_route_map(): 20 """Create, configure and return the routes Mapper""" 21 map = Mapper(directory=config['pylons.paths']['controllers'], 22 always_scan=config['debug']) 23 24 ## Replace the next line with your overides. Overides should generally come 25 ## before the default route defined below 26 # map.connect('overide/url/here', controller='mycontrller', action='send_stuff') 24 def setup_routes(self): 25 """Setup the default TG2 routes 27 26 28 # This route connects your root controller 29 map.connect('*url', controller='root', action='route') 27 Overide this and setup your own routes maps if you want to use routes. 28 """ 29 map = Mapper(directory=config['pylons.paths']['controllers'], 30 always_scan=config['debug']) 30 31 31 return map 32 # Setup a default route for the error controller: 33 map.connect('error/:action/:id', controller='error') 34 # Setup a default route for the root of object dispatch 35 map.connect('*url', controller='root', action='routes_placeholder') 36 37 config['routes.map'] = map 38 32 39 33 There's a single map.connect() call which sets up all urls (via the * wildcard) assigns them to the URL param, and sends them to the RootController in the root.py file in your project's controllers folder. The default environment.py file in your config directory takes this and assigns it to make_map, which is passed in as a configuration element to the RoutesMiddleware setup in middleware.py.:: 40 There's a single map.connect() call which sets up all urls (via the * 41 wildcard) assigns them to the URL param, and sends them to the 42 RootController in the root.py file in your project's controllers folder. 43 When TurboGears loads the environment for your app, it will use this 44 setup_routes method to do it. 34 45 35 # This setups up a set of default route that enables a standard 36 # TG2 style object dispatch. Fell free to overide it with 37 # custom routes. 38 39 make_map = setup.make_default_route_map 46 So to create your own routes, all you need to do is create another map.connect 47 call above the `*url` call that connects you to the root controller. 40 48 41 To define your own custom routes, all you need to do is to replace this with your own make_map implementation. If you want you can set up object dispatch from places other than root.py, or even use routes to define all of your URLs. If you are going to do object dispatch, make sure the controller that you dispatch too inherits from TGController, since that's the controller that knows how to do internal dispatch. 42 49 If you want to start object dispatch from a different root than '/' all you 50 need to do is change the `'*url'` line to mount something somewhere else. 51 52 If you have a very large app, and you want to break down the object dispatch 53 tree for performance reasons, you can do that by defining routes to 54 objects further down the tree. 55 43 56 For more information about how to write routes, you might want to read: 44 57 trunk/docs/main/TG2Philosophy.rst
r4370 r5001 1 2 3 4 TurboGears Concept5 ===================6 7 :Status: Work in progress8 9 .. contents:: Table of Contents10 :depth: 211 12 1 TurboGears 2 is a reinvention of TurboGears and a return to TurboGears' roots. 13 2 … … 27 16 28 17 TurboGears2 returns to that philosophy. It is built on Pylons, but it brings 29 a best-of-breed approach to Pylons. TurboGears 2 is commited to the following 30 Python components and libraries, which are backwards compatable with TurboGears 1.1: 18 a more full-stack approach to pylons. TurboGears 2 is committed to creating 19 reusable components, and to achieving a long-term stable API based on the 20 following Python components and libraries: 31 21 32 22 * Models: SQLAlchemy 33 * Template engines: Genshi 23 * Template engines: Genshi and Mako 34 24 * URL Dispatching: Object dispatch 35 25 * Form Handling: ToscaWidgets 36 37 26 38 27 The zen of TurboGears is:: … … 45 34 46 35 47 Mark Ramm described the relationship between TurboGears and Pylons this way "TurboGears 2 is to Pylons as Ubuntu is to Debian." 36 Mark Ramm described the relationship between TurboGears and Pylons this 37 way "TurboGears 2 is to Pylons as Ubuntu is to Debian." 48 38 49 In other words we're focused on user experience, and creating a novice-friendly environment. We ship a smaller subset of components, and thus are better able to focus, test, and document things so that new users have the best possible experience. 39 In other words we're focused on user experience, and creating a 40 novice-friendly environment. We ship a smaller subset of components, 41 and thus are better able to focus, test, and document things so that new users 42 have the best possible experience. 50 43 51 44 Meanwhile Pylons provides the power and flexibility of the underlying core. 52 45 53 And like Ubuntu, we don't intend to hide that power and flexibility from advanced users, but we know that they want things set up to just work too. 46 And like Ubuntu, we don't intend to hide that power and flexibility from 47 advanced users, but we know that they want things set up to just work too. 54 48 55 Sensible defaults actually encourage code re-use within TurboGears because they make it possible for a group of TurboGears components to share assumptions about how things will work. 49 Sensible defaults actually encourage code re-use within TurboGears because 50 they make it possible for a group of TurboGears components to share 51 assumptions about how things will work. trunk/docs/main/TGandPyAMF.rst
r5000 r5001 80 80 81 81 @expose() 82 def simple(self, **kwargs):82 def gateway(self, *args, **kwargs): 83 83 return use_wsgi_app(GatewayController) 84 84 85 86 You'll need to import use_wsgi_app from tg, and your GatewayController from 87 wherever you put it. 85 Of course, you'll need to import use_wsgi_app from tg, and your 86 GatewayController from wherever you put it. But once you've done those 87 things you'll have a AMF Gateway mounted at /gateway which you can use from 88 flex. 88 89 89 90 trunk/docs/main/WhatsNew.rst
r4559 r5001 87 87 * ``tg-admin toolbox`` --> ``paster toolbox`` 88 88 * ``tg-admin shell`` --> ``paster shell`` 89 * ``tg-admin sql create`` --> ``paster setup_app development.ini`` 89 90 90 91 Project layout changes