You just posted the last row of the traceback, if you look at the previous ones you should be able to see the one that is trying to access tg.request. If that is outside of a controller, then that is the source of the crash.
On Mon, Feb 17, 2014 at 10:09 PM, Ricardo Molina < [email protected]> wrote: > I have removed all the the switches (operator.is_active('foo')) from my > code and I'm still getting this error. Therefore I think I am not plugging > it in correctly, probably because I am using a CustomConfig class that > inherits from AppConfig. > > Regards. > > El lunes, 17 de febrero de 2014 09:23:39 UTC+1, Alessandro Molina escribió: >> >> It looks to me that you are correctly enabling switchboard. It looks like >> it's trying to access the request before outside of an HTTP request. >> I never used switchboard myself, so I don't know how it works, but I >> suppose you might be trying to access to a switch value (is_active) outside >> of a request. >> >> >> On Mon, Feb 17, 2014 at 12:05 AM, Ricardo Molina <[email protected] >> > wrote: >> >>> I am trying to use switchboard-tg2 0.3 [ https://pypi.python.org/ >>> pypi/switchboard-tg2/0.3 ] in my TurboGears 222 app, but I am getting >>> this error: >>> >>> Starting subprocess with file monitor >>> 2014-02-1392590872 23:47:52,729 WARNI [tgext.pluggable] TurboGears >>> version < 2.3.1, disabling support for SQLAlchemy 0.9 >>> 2014-02-1392590872 23:47:52,731 INFO [tgext.pluggable] Plugging >>> switchboard_tg2 >>> Traceback (most recent call last): >>> ... >>> ... >>> ... >>> * File >>> "/home/ricardo/env/tg222/local/lib/python2.7/site-packages/Paste-1.7.5.1-py2.7.egg/paste/registry.py", >>> line 197, in _current_obj* >>> * 'thread' % self.____name__)* >>> *TypeError: No object (name: request) has been registered for this >>> thread* >>> >>> >>> This is my *app_cfg.py* file, where I have plugged in switchboard_tg2: >>> >>> # -*- coding: utf-8 -*- >>> >>> #some imports >>> from tg.configuration import AppConfig >>> from tg.configuration.auth import TGAuthMetadata >>> import neptuno.util as np_util >>> *from tgext.pluggable import plug* >>> >>> #This tells to TurboGears how to retrieve the data for your user >>> class ApplicationAuthMetadata(TGAuthMetadata): >>> def __init__(self, sa_auth): >>> self.sa_auth = sa_auth >>> >>> def get_user(self, identity, userid): >>> return self.sa_auth.dbsession.query(self.sa_auth.user_class). >>> filter_by(user_name=userid).first() >>> >>> def get_groups(self, identity, userid): >>> return [g.group_name for g in identity['user'].groups] >>> >>> def get_permissions(self, identity, userid): >>> return [p.permission_name for p in identity['user'].permissions] >>> >>> class CustomConfig(AppConfig): >>> >>> def __init__(self): >>> super(CustomConfig, self).__init__() >>> self.use_toscawidgets = False >>> >>> self.renderers = [] >>> >>> self.package = sapns >>> >>> #Enable json in expose >>> self.renderers.append('json') >>> #Set the default renderer >>> self.default_renderer = 'jinja' >>> self.renderers.append('jinja') >>> *self.renderers.append('mako')* >>> self.jinja_extensions = ['jinja2.ext.i18n'] >>> self.use_dotted_templatenames = False # makes TG 2.1.5 work >>> >>> #Configure the base SQLALchemy Setup >>> self.use_sqlalchemy = True >>> self.model = sapns.model #@UndefinedVariable >>> self.DBSession = sapns.model.DBSession #@UndefinedVariable >>> >>> # Configure the authentication backend >>> self.auth_backend = 'sqlalchemy' >>> self.sa_auth.dbsession = model.DBSession >>> self.sa_auth.user_class = model.User >>> #self.sa_auth.group_class = model.Group >>> #self.sa_auth.permission_class = model.Permission >>> self.sa_auth.authmetadata = ApplicationAuthMetadata(self. >>> sa_auth) >>> >>> # override this if you would like to provide a different who >>> plugin for >>> # managing login and logout of your application >>> self.sa_auth.form_plugin = None >>> >>> # override this if you are using a different charset for the >>> login form >>> self.sa_auth.charset = 'utf-8' >>> >>> # You may optionally define a page where you want users to be >>> redirected to >>> # on login: >>> self.sa_auth.post_login_url = '/post_login' >>> >>> # You may optionally define a page where you want users to be >>> redirected to >>> # on logout: >>> self.sa_auth.post_logout_url = '/post_logout' >>> >>> def setup_routes(self): >>> >>> from tg.configuration import config >>> from routes.mapper import Mapper >>> >>> map_ = Mapper(directory=config['pylons.paths']['controllers'], >>> always_scan=config['debug']) >>> >>> # Setup a default route for the root of object dispatch >>> controller_ = 'root' >>> root_folder = config.get('app.root_folder') >>> if root_folder: >>> controller_ = '%s/root' % root_folder >>> >>> map_.connect('*url', controller=controller_, >>> action='routes_placeholder') >>> >>> config['routes.map'] = map_ >>> >>> base_config = CustomConfig() >>> *plug(base_config, 'switchboard_tg2')* >>> >>> >>> >>> Does anyone know how to solve this issue (TypeError: No object (name: >>> request) has been registered for this thread)? >>> >>> Thank you >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "TurboGears" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> >>> Visit this group at http://groups.google.com/group/turbogears. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/turbogears. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/groups/opt_out.

