Jonathan Vanasco
2018-05-06 20:27:56 UTC
I'm doing some housekeeping on an app that has been a bit too lax on
keeping to it's own coding standards.
There have been a bunch of updates over the past few years to the views
systems, so I'm hoping something may work for our needs...
In a handful of sections, it utilize class based views that rely on
inheritance for setup routines.
for example...
class Foo(object):
def __init__(self, request):
self.request = request
... common setup ...
@view_config(route_name="bar",)
def bar(self):
pass
I was wondering if it is possible to hook into pyramid after the Foo() is
instantiated, but before `Foo.bar` is called.
What I want to accomplish, in case someone has a better suggestion:
* The views i'm dealing with generally handle form processing on an API.
* There are a handful of common setup and form validation routines that
happen on these
* I'd like to define and trigger the common validation in a parent class,
to ensure it runs. a handful of views were not calling the correct
validation routines, because people make easy mistakes like that.
* I could integrate this processing into __init__, but error reporting
would be much easier if it occurs after __init__, so I can utilize the
class instance.
keeping to it's own coding standards.
There have been a bunch of updates over the past few years to the views
systems, so I'm hoping something may work for our needs...
In a handful of sections, it utilize class based views that rely on
inheritance for setup routines.
for example...
class Foo(object):
def __init__(self, request):
self.request = request
... common setup ...
@view_config(route_name="bar",)
def bar(self):
pass
I was wondering if it is possible to hook into pyramid after the Foo() is
instantiated, but before `Foo.bar` is called.
What I want to accomplish, in case someone has a better suggestion:
* The views i'm dealing with generally handle form processing on an API.
* There are a handful of common setup and form validation routines that
happen on these
* I'd like to define and trigger the common validation in a parent class,
to ensure it runs. a handful of views were not calling the correct
validation routines, because people make easy mistakes like that.
* I could integrate this processing into __init__, but error reporting
would be much easier if it occurs after __init__, so I can utilize the
class instance.
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+***@googlegroups.com.
To post to this group, send email to pylons-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/ee79f36e-f7f1-4f75-abb3-d4e31ca879f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+***@googlegroups.com.
To post to this group, send email to pylons-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/ee79f36e-f7f1-4f75-abb3-d4e31ca879f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.