Quantcast
Channel: User Michael Merickel - Stack Overflow
Browsing index pages (41 articles)
↧

Answer by Michael Merickel for Editing Pyramid configuration .ini file at...

This is not the purpose of the configuration.ini file. It is explicitly intended to be readonly settings for your app. There is no thread-safety built into the settings dictionary. That being said,...

View Article


Comment by Michael Merickel on Is is possible to run a pyramid application...

Because you mention pserve I'll just throw out there that gist.github.com/mmerickel/ddcd86d3603979cac279d228e08716ce is basically a 95% replacement for all of pserve's functionality but works with any...

View Article


Answer by Michael Merickel for control order that routes are matched when...

The way the phases work in Pyramid doesn't allow you to re-order actions within a phase. Basically imagine that every call to config.add_route gets appended to a list, and then later that list is...

View Article

Answer by Michael Merickel for Pyramid fileresponse with header

The pattern in your example is valid, you should see the Content-Disposition header set on the response that way. As far as displaying it instead of downloading as an attachment I believe that the...

View Article

Answer by Michael Merickel for @reify executes database queries every time...

A signature like def user_details(self, user_id) has too many args to be supported by @reify or even @property. It should be def user_details(self). The reify decorator will then modify the attribute...

View Article


Answer by Michael Merickel for How can I access a custom section in a Pyramid...

If you want to do that you'll have to parse the config file yourself. The section-isolation behavior you're seeing is intentional.def main(global_conf, **settings): parser = ConfigParser({'here':...

View Article

Answer by Michael Merickel for How can one combine pyramid_beaker...

At least one pattern is to decorate a closure that only accepts the args you want to cache and accesses other variables like request/dbsession from nonlocal scope.def view_func(request):...

View Article

Answer by Michael Merickel for How do I do dependency injection in a python's...

To do this you'll need to define a custom view mapper which is the resource that is responsible for invoking a view. I'm unaware of any view mappers that come out of the box that will do this for you...

View Article


Answer by Michael Merickel for Python Pyramid optional url segment

The view_defaults do not stack the way you probably think they do. You should only define view_defaults once for a class, and then it will add parameters to every view_config defined inside the class.

View Article


Answer by Michael Merickel for Inconsistent ACL Permission on Pyramid/Websauna

I suspect websauna is not invoking your resolve_custom_principals function and is rather using its default resolve_principals function? I think it's pretty clear that the principals pulled in when...

View Article

Answer by Michael Merickel for Trying to install Pyramid package with "python...

When you run python setup.py install directly, you are not using pip, so the version of pip you have installed is irrelevant. This command is antiquated, should not be used, etc, etc. The right answer...

View Article

Answer by Michael Merickel for pyramid security authenticating request

By default, authenticated_userid will not change in the same request in which you invoked remember. It is merely setting a cookie on the response object which the client will return on the NEXT request...

View Article

Answer by Michael Merickel for Deserialize Multidict using Colander

I suspect you'll want to use something like request.POST.mixed() which will return a list for the name key if multiple values were sent (but not a list if just one value) combined with maybe a colander...

View Article


Answer by Michael Merickel for How to port /{controller}/{action}/{id} routes...

Pyramid on its own requires granular route definitions. You can write helpers for this likedef add_action_routes(config, name, path=None): if path is None: path = name if not path.endswith('/'): path...

View Article

Answer by Michael Merickel for Python pyramid encrypted session recommendation

I recommend https://docs.pylonsproject.org/projects/pyramid-nacl-session/en/latest/ which is an official addon for handling encrypted sessions. Beaker is also great and you can use that too.

View Article


Answer by Michael Merickel for Python pyramid i18n and pytest

I suspect you aren't invoking config.begin() and config.end() correctly around your tests such that the threadlocals are active. It completely depends on how your tests look what this actually means...

View Article

Answer by Michael Merickel for How to use Pyramid to host static files at an...

filepath needs to be a url if you're expecting to put it as the src attribute in an img tag in your HTML. The browser needs to request the asset. You should be doing something like...

View Article


Answer by Michael Merickel for Getting current route in pyramid view test

It's not super easy to mock current_route_path via DummyRequest because it relies on an IRoute object attached to it named matched_route as it's doing request.matched_route.name to get the route name...

View Article

Answer by Michael Merickel for No transaction in add_finished_callback() -...

add_finished_callback runs after tweens and is generally where cleanup occurs, and is unordered, thus relying on a database connection to be open there is not a good idea.It's also worth nothing that...

View Article

Answer by Michael Merickel for Pyramid not included in Python virtualenv

You mentioned it's using buildout - I assume this is zc.buildout. buildout usually manages its own virtualenv and handles installing all of the necessary dependencies. It really depends on how that...

View Article
Browsing index pages (41 articles)


Latest Images