Changeset 5001

Show
Ignore:
Timestamp:
07/18/08 19:51:41 (6 months ago)
Author:
mramm
Message:

Updating the Routes docs + several minor fixes to other docs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docs/main/RoutesIntegration.rst

    r4575 r5001  
    99    :depth: 2 
    1010 
    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.   
     11TurboGears2 does URL dispatch with a combination of TG1 style object dispatch,  
     12and built in Routes integration.  By default you don't need to think about  
     13Routes at all, because the framework sets up a default route to your  
     14RootController, which sees that the action is route, and does object  
     15dispatch in the same way that TurboGears 1 did.   
    1316 
    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 :: 
     17But if you want to create special routes that overide Object Dispatch,  
     18you can easily do that, just by providing your own function to setup the  
     19routes map. YOu can update the routes defaults by overriding the setup_routes 
     20method of the base_config object in app_cfg.py.   
    1521 
    16   from pylons import config 
    17   from routes import Mapper 
     22The standard setup_routes method looks like this:: 
    1823 
    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') 
     24def setup_routes(self): 
     25    """Setup the default TG2 routes 
    2726     
    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']) 
    3031 
    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     
    3239 
    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.:: 
     40There's a single map.connect() call which sets up all urls (via the *  
     41wildcard) assigns them to the URL param, and sends them to the  
     42RootController in the root.py file in your project's controllers folder. 
     43When TurboGears loads the environment for your app, it will use this  
     44setup_routes method to do it.    
    3445 
    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 
     46So to create your own routes, all you need to do is create another map.connect 
     47call above the `*url` call that connects you to the root controller.  
    4048 
    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   
     49If you want to start object dispatch from a different root than '/' all you  
     50need to do is change the `'*url'` line to mount something somewhere else.  
     51 
     52If you have a very large app, and you want to break down the object dispatch  
     53tree for performance reasons, you can do that by defining routes to  
     54objects further down the tree.  
     55 
    4356For more information about how to write routes, you might want to read: 
    4457 
  • trunk/docs/main/TG2Philosophy.rst

    r4370 r5001  
    1  
    2  
    3  
    4 TurboGears Concept 
    5 =================== 
    6  
    7 :Status: Work in progress 
    8  
    9 .. contents:: Table of Contents 
    10     :depth: 2 
    11  
    121TurboGears 2 is a reinvention of TurboGears and a return to TurboGears' roots. 
    132 
     
    2716 
    2817TurboGears2 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: 
     18a more full-stack approach to pylons.   TurboGears 2 is committed to creating 
     19reusable components, and to achieving a long-term stable API based on the  
     20following  Python components and libraries: 
    3121 
    3222    * Models: SQLAlchemy 
    33     * Template engines: Genshi 
     23    * Template engines: Genshi and Mako 
    3424    * URL Dispatching: Object dispatch 
    3525    * Form Handling: ToscaWidgets 
    36  
    3726 
    3827The zen of TurboGears is:: 
     
    4534     
    4635 
    47 Mark Ramm described the relationship between TurboGears and Pylons this way "TurboGears 2 is to Pylons as Ubuntu is to Debian." 
     36Mark Ramm described the relationship between TurboGears and Pylons this  
     37way "TurboGears 2 is to Pylons as Ubuntu is to Debian." 
    4838 
    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. 
     39In other words we're focused on user experience, and creating a  
     40novice-friendly environment.  We ship a smaller subset of components,  
     41and thus are better able to focus, test, and document things so that new users 
     42have the best possible experience. 
    5043 
    5144Meanwhile Pylons provides the power and flexibility of the underlying core.  
    5245 
    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.   
     46And like Ubuntu, we don't intend to hide that power and flexibility from  
     47advanced users, but we know that they want things set up to just work too.   
    5448 
    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.  
     49Sensible defaults actually encourage code re-use within TurboGears because  
     50they make it possible for a group of TurboGears components to share  
     51assumptions about how things will work.  
  • trunk/docs/main/TGandPyAMF.rst

    r5000 r5001  
    8080 
    8181@expose() 
    82 def simple(self, **kwargs): 
     82def gateway(self, *args, **kwargs): 
    8383    return use_wsgi_app(GatewayController) 
    8484 
    85  
    86 You'll need to import use_wsgi_app from tg, and your GatewayController from  
    87 wherever you put it.  
     85Of course, you'll need to import use_wsgi_app from tg, and your  
     86GatewayController from wherever you put it. But once you've done those  
     87things you'll have a AMF Gateway mounted at /gateway which you can use from  
     88flex.  
    8889 
    8990    
  • trunk/docs/main/WhatsNew.rst

    r4559 r5001  
    8787  * ``tg-admin toolbox`` --> ``paster toolbox`` 
    8888  * ``tg-admin shell`` --> ``paster shell`` 
     89  * ``tg-admin sql create`` --> ``paster setup_app development.ini`` 
    8990 
    9091Project layout changes