Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:37:13+00:00 2026-06-11T15:37:13+00:00

I’m using Pyramid 1.4a1 and I have this subscriber predicate: class RouteName(object): ”’ Subscriber

  • 0

I’m using Pyramid 1.4a1 and I have this subscriber predicate:

class RouteName(object):
    '''
    Subscriber predicate to check against route name.
    '''

    def __init__(self, value, config):
        self.value = value
        self.config = config

    def text(self):
        return 'route_name = %s' % self.value
    phash = text

    def __call__(self, event):
        route_name = event.request.matched_route.name
        return route_name == self.value

And I add it like so:

config.add_subscriber_predicate('route_name', RouteName)

However, whenever I try to use it, like so:

@subscriber(ContextFound, route_name='user.register')
def check_invitation(event):
    # Check invitation token before running registration view code ...

I get this traceback:

Traceback (most recent call last):
  File "/Workspace/Personal/project/.env/bin/pserve", line 8, in <module>
    load_entry_point('pyramid==1.4a1', 'console_scripts', 'pserve')()
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 47, in main
    return command.run()
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 290, in run
    relative_to=base, global_conf=vars)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 318, in loadapp
    return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/util.py", line 56, in fix_call
    val = callable(*args, **kw)
  File "/Workspace/Personal/project/project/__init__.py", line 49, in main
    return config.make_wsgi_app()
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 955, in make_wsgi_app
    self.commit()
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 629, in commit
    self.action_state.execute_actions(introspector=self.introspector)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 1083, in execute_actions
    tb)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 1075, in execute_actions
    callable(*args, **kw)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/adapters.py", line 53, in register
    order, preds, phash = predlist.make(self, **predicates)
  File "/Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/config/util.py", line 264, in make
    pred = predicate_factory(val, config)
pyramid.exceptions.ConfigurationExecutionError: <type 'exceptions.TypeError'>: object.__new__() takes no parameters
  in:
  Line 80 of file /Workspace/Personal/project/.env/local/lib/python2.7/site-packages/pyramid/events.py:
    config.add_subscriber(wrapped, iface, **self.predicates)

I also have a custom view predicate registered in the same manner, and it works just fine, so I don’t know what I’m doing wrong here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:37:14+00:00Added an answer on June 11, 2026 at 3:37 pm

    I think you have a typo in your code somewhere. The following application
    works under 1.4a1. If you visit / it prints checked. If you visit /another,
    it does not:

    from wsgiref.simple_server import make_server
    from pyramid.config import Configurator
    from pyramid.events import subscriber, ContextFound
    from pyramid.view import view_config
    
    class RouteName(object):
        '''
        Subscriber predicate to check against route name.
        '''
    
        def __init__(self, value, config):
            self.value = value
            self.config = config
    
        def text(self):
            return 'route_name = %s' % self.value
    
        phash = text
    
        def __call__(self, event):
            route_name = getattr(event.request.matched_route, 'name', None)
            return route_name == self.value
    
    @subscriber(ContextFound, route_name='home')
    def check(event):
        print 'checked'
    
    @view_config(renderer='string', route_name='home')
    def home(request):
        return 'home'
    
    @view_config(renderer='string', route_name='another')
    def another(request):
        return 'another'
    
    if __name__ == '__main__':
        config = Configurator()
        config.add_subscriber_predicate('route_name', RouteName)
        config.add_route('home', '/')
        config.add_route('another', '/another')
        config.scan()
        app = config.make_wsgi_app()
        server = make_server('0.0.0.0', 8080, app)
        server.serve_forever()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.