Ok. This is on a new quickstarted project with my changes for custom
routes. Here is the traceback and the changes to app_cfg.py and
root.py are bellow. If it's helpful I can upload the entire project.

URL: http://localhost:8080/prefix/1/about
File '/Users/carl/tg2env/lib/python2.5/site-packages/WebError-0.10.1-
py2.5.egg/weberror/evalexception.py', line 431 in respond
  app_iter = self.application(environ, detect_start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/TurboGears2-2.0b7-
py2.5.egg/tg/configuration.py', line 631 in wrapper
  return app(environ, start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/TurboGears2-2.0b7-
py2.5.egg/tg/configuration.py', line 534 in remover
  return app(environ, start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/repoze.tm2-1.0a3-
py2.5.egg/repoze/tm/__init__.py', line 19 in __call__
  result = self.application(environ, save_status_and_headers)
File '/Users/carl/tg2env/lib/python2.5/site-packages/
ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/middleware.py', line
36 in __call__
  return self.wsgi_app(environ, start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/
ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/middleware.py', line
59 in wsgi_app
  resp = req.get_response(self.application)
File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1325
in get_response
File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1293
in call_application
File '/Users/carl/tg2env/lib/python2.5/site-packages/
ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/
resource_injector.py', line 67 in _injector
  resp = req.get_response(app)
File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1325
in get_response
File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1293
in call_application
File '/Users/carl/tg2env/lib/python2.5/site-packages/Beaker-1.2.2-
py2.5.egg/beaker/middleware.py', line 81 in __call__
  return self.app(environ, start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/Beaker-1.2.2-
py2.5.egg/beaker/middleware.py', line 160 in __call__
  return self.wrap_app(environ, session_start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/Routes-1.10.3-
py2.5.egg/routes/middleware.py', line 130 in __call__
  response = self.app(environ, start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/Pylons-0.9.7-
py2.5.egg/pylons/wsgiapp.py', line 125 in __call__
  response = self.dispatch(controller, environ, start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/Pylons-0.9.7-
py2.5.egg/pylons/wsgiapp.py', line 324 in dispatch
  return controller(environ, start_response)
File '/Users/carl/tg2env/lib/python2.5/site-packages/Pylons-0.9.7-
py2.5.egg/pylons/controllers/core.py', line 217 in __call__
  response = self._inspect_call(self.__before__)
File '/Users/carl/tg2env/lib/python2.5/site-packages/Pylons-0.9.7-
py2.5.egg/pylons/controllers/core.py', line 107 in _inspect_call
  result = self._perform_call(func, args)
File '/Users/carl/tg2env/lib/python2.5/site-packages/TurboGears2-2.0b7-
py2.5.egg/tg/controllers.py', line 125 in _perform_call
  controller.decoration.run_hooks('before_validate', remainder,
AttributeError: 'function' object has no attribute 'decoration'


Here is my app_cfg.py:

# -*- coding: utf-8 -*-
"""
Global configuration file for TG2-specific settings in custom-routes.

This file complements development/deployment.ini.

"""

from tg.configuration import AppConfig, Bunch
# Carl: needed for setup_custom_routes
from tg.configuration import Mapper, config

import custom_routes
from custom_routes import model
from custom_routes.lib import app_globals, helpers

# Carl: added custom routes function to override the default in
AppConfig
def custom_setup_routes(self):
    """Setup the default TG2 routes

    Override this and set up your own routes maps if you want to use
routes.
    """
    map = Mapper(directory=config['pylons.paths']['controllers'],
                always_scan=config['debug'])

    map.connect('prefix', 'prefix/{id}/{action}', controller='root')

    # Setup a default route for the root of object dispatch
    map.connect('*url', controller='root',
action='routes_placeholder')

    config['routes.map'] = map

# Carl: assign the custom routes function to AppConfig.
# It's equivalent to subclassing AppConfig in this case
AppConfig.setup_routes = custom_setup_routes

base_config = AppConfig()
base_config.renderers = []

base_config.package = custom_routes

#Set the default renderer
base_config.default_renderer = 'genshi'
base_config.renderers.append('genshi')
# if you want raw speed and have installed chameleon.genshi
# you should try to use this renderer instead.
# warning: for the moment chameleon does not handle i18n translations
#base_config.renderers.append('chameleon_genshi')

#Configure the base SQLALchemy Setup
base_config.use_sqlalchemy = True
base_config.model = custom_routes.model

And here are my changes to the RootController:


# -*- coding: utf-8 -*-
"""Main Controller"""

from tg import expose, flash, require, url, request, redirect,
validate
from pylons.i18n import ugettext as _, lazy_ugettext as l_

from custom_routes.lib.base import BaseController
# Carl: DecoratedController will be the base class for the root
controller
from tg.controllers import DecoratedController


from custom_routes.model import DBSession, metadata
from custom_routes.controllers.error import ErrorController

__all__ = ['RootController']

class RootController(DecoratedController):
#class RootController(BaseController):
# The rest is the same










On Mar 16, 1:09 pm, Mark Ramm <[email protected]> wrote:
> A code sample, and traceback would help us help you better ;)
>
>
>
> On Mon, Mar 16, 2009 at 2:43 PM, Carl <[email protected]> wrote:
>
> > Hello Gustavo,
> > What didn't work for me is that if my controller I just  subclasses
> > the BaseController, then it looks like the routing in app_cfg.py is
> > ignored. TGController  calls a _get_routing_info() function defined in
> > ObjectDispatchController that does just object dispatch.
>
> > Gigi
>
> > On Mar 16, 9:46 am, Gustavo Narea <[email protected]> wrote:
> >> Hello, Carl.
>
> >> On Saturday March 14, 2009 16:49:17 Carl wrote:
>
> >> > I tried it but it didn't work for me. Maybe I got the URL syntax
> >> > wrong. What URLs map to your custom routes?
>
> >> Those whose paths look like: /<string>/<integer>
>
> >> > Also, from reading the
> >> > Routes manual I got the impression that variables are words with a
> >> > colon in the end (e.g 'prefix:'), but your routes look like regular
> >> > expressions.
>
> >> Placeholders can be defined with {brackets} and :colons:, but the later is
> >> deprecated.
>
> >> In my case I just wanted to force an integer in one of the variables, 
> >> hence I
> >> used a regular expression. It's optional.
>
> >> Cheers!
>
> >> PS: What didn't exactly work?
> >> --
> >> Gustavo Narea <xri://=Gustavo>.
> >> | Tech blog: =Gustavo/(+blog)/tech  ~  About me: =Gustavo/about |
>
> --
> Mark Ramm-Christensen
> email: mark at compoundthinking dot com
> blog:www.compoundthinking.com/blog
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to