Pylons / pyramid

Pyramid - A Python web framework
https://trypyramid.com/
Other
3.97k stars 887 forks source link

context matching in views and inheritance (traversal) #3714

Closed silenius closed 1 year ago

silenius commented 2 years ago

Hello,

given 2 ressources and a @view_config:

class A:
    ...

class B(A):
    ...

@view_config(context=A, name='foo')
def foo():
    ...

is there a way to match /someB/foo to A foo() if /someB/foo resolves to context B, but no @view_config(context=B, name='foo') has been defined (but as B is a child of A it could matches foo() registered on A) ?

Thanks

mmerickel commented 2 years ago

Your example should invoke the foo view for a context of your B and name=foo. Do you have a full example where it does not?

silenius commented 1 year ago

Sorry for late reply, you're right, it was a mistake on my side