Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

zope.interface 3.6.4 breaks URL dispatch #232

Closed
Beanfield opened this Issue · 6 comments

2 participants

@Beanfield

After install zope.interface 3.6.4 my route lookup failed. After debugging I found that the correct route would match (shown using PYRAMID_DEBUG_ROUTEMATCH), but afterwards during the view callable lookup an incorrect list of Multiview callables would be returned. I am using Akhet with pyramid_handlers, so the lookup usually returns methods of a particular handler class, but this time it returned every method of every handler in an incorrect order. This results in the incorrect view callable being called, even though the route matched.

Downgrading to zope.interface 3.6.3 resolved the issue. I tried this with Pyramid 1.1a and 1.1b1.

@mcdonc
Owner

Could you provide maybe your configuration, so I can repeat this? Without being able to repeat this, I can't take any action on it, as all the akhet tests that run on zope.interface 3.6.1 also run OK on zope.interface. 3.6.4; all the pyramid_handler tests pass and all the Pyramid tests pass.

@Beanfield

It is a decent sized application, so I am not sure which parts are relevant. I will try to narrow it down.

@Beanfield Beanfield closed this
@Beanfield Beanfield reopened this
@Beanfield

I have made an example project where the URL dispatch is working incorrectly at: https://github.com/Beanfield/BreakPyramid

It is a default Akhet template with two handlers. The two handlers have methods with the same name. When I try to go to /another/edit/whatever I get the result that would have been returned from /test/edit/whatever.

In the output it tells me that the url matched the "Another" handler:

2011-07-12 14:27:57,315 route matched for url http://localhost:5000/another/edit/09; route_name: 'another action', path_info: '/another/edit/09', pattern: '/another/{action}/{id}', matchdict: {'action': u'edit', 'id': u'09'}, predicates: []

My site-packages directory has these packages:

Akhet-1.0-py2.7.egg
Beaker-1.5.4-py2.7.egg
Chameleon-2.0_rc13-py2.7.egg
Mako-0.4.1-py2.7.egg
MarkupSafe-0.12-py2.7-macosx-10.5-fat3.egg
Paste-1.7.5.1-py2.7.egg
PasteDeploy-1.5.0-py2.7.egg
PasteScript-1.7.3-py2.7.egg
Pygments-1.4-py2.7.egg
SQLAHelper-1.0b1-py2.7.egg
SQLAlchemy-0.7.1-py2.7-macosx-10.5-fat3.egg
Tempita-0.5.1-py2.7.egg
TestApp.egg-link
WebError-0.10.3-py2.7.egg
WebOb-1.1beta1-py2.7.egg
easy-install.pth
pip-0.8.1-py2.7.egg
pyramid-1.1b1-py2.7.egg
pyramid_beaker-0.5-py2.7.egg
pyramid_handlers-0.1-py2.7.egg
pyramid_tm-0.1-py2.7.egg
pyramid_zcml-0.2-py2.7.egg
repoze.lru-0.3-py2.7.egg
setuptools-0.6c11-py2.7.egg
setuptools-0.6c12dev_r88846-py2.7.egg
setuptools.pth
transaction-1.1.1-py2.7.egg
translationstring-0.3-py2.7.egg
venusian-0.9-py2.7.egg
zope.component-3.10.0-py2.7.egg
zope.configuration-3.7.4-py2.7.egg
zope.deprecation-3.4.1-py2.7.egg
zope.event-3.5.0_1-py2.7.egg
zope.i18nmessageid-3.5.3-py2.7-macosx-10.5-fat3.egg
zope.interface-3.6.4-py2.7-macosx-10.5-fat3.egg
zope.schema-3.8.0-py2.7.egg
zope.sqlalchemy-0.6.1-py2.7.egg

Once I downgrade zope.interface to 3.6.3 the application works as expected

@mcdonc
Owner

Thanks so much! I'll try to diagnose ASAP.

@mcdonc
Owner

Sure enough, I've reproduced it. May not have it diagnosed today, but it's important so stay tuned. Thanks!

@mcdonc mcdonc closed this issue from a commit
@mcdonc mcdonc - Views associated with routes with spaces in the route name may not …
…have

  been looked up correctly when using Pyramid with ``zope.interface`` 3.6.4
  and better.

Closes #232.
873d9be
@mcdonc mcdonc closed this in 873d9be
@mcdonc
Owner

This was a stupid one.

zope.interface 3.6.4 added a hash method to the zope.interface.interface.InterfaceClass class. The constructor of this class as a side effect would cause hash to be executed (this obviously never happened before, as it didn't possess as hash in 3.6.3 and below) when classifying it.

The hash method generates a hash value based on the name and module of the interface class. In Pyramid, an interface is generated for each route. The route's name is used as a component of the generated interface.

When a route had spaces in its name, some insane code in zope.interface converted the name into None and used the passed name value as the doc, as per this code in zope.interface.interface:

class Element(object):

    # We can't say this yet because we don't have enough
    # infrastructure in place.
    #
    #implements(IElement)

    def __init__(self, __name__, __doc__=''):
        """Create an 'attribute' description
        """
        if not __doc__ and __name__.find(' ') >= 0:
            __doc__ = __name__
            __name__ = None

We work around the issue by always passing a nonempty doc when generating an interface for a route. The fix will be present in 1.1b2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.