pyramid

Trying to get Pyramid running under Apache + mod_wsgi but it's failing

笑着哭i 提交于 2019-11-29 16:00:47
问题 I've got Apache2 running with mod_wsgi installed. I've confirmed that mod_wsgi actually works by following this. The problem comes when I try to get Pyramid running. I get an Internal Server Error and my Apache error log contains the exception: AssertionError: The EvalException middleware is not usable in a multi-process environment Here's my VHost: <VirtualHost *:80> ServerName pyramidtest.dev DocumentRoot /srv/pyramidtest.dev/www/ AssignUserID pyramidtest nogroup WSGIScriptAlias / /srv

Check if a user has a permission in pyramid (pylons 2)?

和自甴很熟 提交于 2019-11-29 11:38:17
How do i check if a user has a permission in pyramid. For example, I want to show some HTML only if a user has some permission, but have the view available for everybody. The usual method is: from pyramid.security import has_permission has_permission('view', someresource, request) See also http://docs.pylonsproject.org/projects/pyramid/1.0/narr/security.html#debugging-imperative-authorization-failures and http://docs.pylonsproject.org/projects/pyramid/1.0/api/security.html#pyramid.security.has_permission 来源: https://stackoverflow.com/questions/4916127/check-if-a-user-has-a-permission-in

Why is my log level not being used when using loadapp from paste.deploy?

左心房为你撑大大i 提交于 2019-11-29 08:49:19
I want to temporailiy turn on debug messages in a production pyramid web project so I adjusted the production.ini file, pushed it to Heroku and saw only error and warn level messages. So I thought, that seems odd since if I start the pyramid application like the following on my local PC I get all the log level messages. env/bin/pserve production.ini OK, so that's not exactly how it runs on Heroku, it is actually run from a little bit of python that looks like this (in a file called runapp.py ): import os from paste.deploy import loadapp from waitress import serve if __name__ == "__main__":

Chameleon templates for javascript files?

ぃ、小莉子 提交于 2019-11-29 07:33:09
I am developing a simple pyramid application where I am using JQuery to do AJAX requests. I have until now had my javascript code within my chameleon templates. Now I want to extract my javascript into another location (e.g. as static resources). My problem is that I find my javascript code relies on dynamically generated content like so: $.post("${request.route_url('my_view')}",{'data': 'some data'}, function(html){ $("#destination").html(html); }); The dynamic element being: "${request.route_url('my_view')}" Which is calling the route_url method of the request object within the template. Is

How to set file name in response

≡放荡痞女 提交于 2019-11-29 07:15:01
I know about content-disposition but I read what it uses for email messages. And I want to know how I can set file name with content-type. ps I use Pyramid framework edit: Web site has button 'download' how to perform Response object for file name too, like return Response(body=f.read(), content_type='application/octet-stream') and what I need to do for showing correct file name in browser. You need to set the filename parameter of the Content-Disposition header like so: response.content_disposition = 'attachment; filename="my_filename.txt"' 来源: https://stackoverflow.com/questions/9991292/how

How to use template inheritance with Chameleon?

纵然是瞬间 提交于 2019-11-29 01:53:52
I am using latest Pyramid to build a web app. Somehow we have started using Chameleon as the template engine. I have used Mako before and it was extremely simple to create a base template. Is this possible with chameleon as well? I have tried to look through the docs but I can not seem to find an easy solution. With Chameleon >= 2.7.0 you can use the "load" TALES expression. Example: main.pt: <html> <head> <div metal:define-slot="head"></div> </head> <body> <ul id="menu"> <li><a href="">Item 1</a></li> <li><a href="">Item 2</a></li> <li><a href="">Item 3</a></li> </ul> <div metal:define-slot=

How do I split models.py into different files for different models in Pyramid?

↘锁芯ラ 提交于 2019-11-28 21:34:19
问题 I am new to pyramid and have been struggling to make some changes to my project. I am trying to split my models/Classes into individual files instead of a single models.py file. In order to do so I have removed the old models.py and created a models folder with __init__.py file along with one file for each class. In __init__.py I imported the class by using from .Foo import Foo . This makes the views work correctly and they can initialize an object. But running the initializedb script does

Debug Pylons application through Eclipse

血红的双手。 提交于 2019-11-28 21:14:15
问题 I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? 回答1: Create a new launch configuration (Python Run) Main tab Use paster-script.py as main module (you can find it in the Scripts sub-directory in your python installation directory) Don't forget to add the root folder of your application in the PYTHONPATH zone

SQLAlchemy - Getting a list of tables

穿精又带淫゛_ 提交于 2019-11-28 20:45:04
问题 I couldn't find any information about this in the documentation, but how can I get a list of tables created in SQLAlchemy? I used the class method to create the tables. 回答1: All of the tables are collected in the tables attribute of the SQLAlchemy MetaData object. To get a list of the names of those tables: >>> metadata.tables.keys() ['posts', 'comments', 'users'] If you're using the declarative extension, then you probably aren't managing the metadata yourself. Fortunately, the metadata is

Multiple domains and subdomains on a single Pyramid instance

谁说我不能喝 提交于 2019-11-28 19:38:54
I'm looking to have multiple domains and subdomains on a single Pyramid instance. However, I can't seem to find any documentation on it. The last question referred to a glossary with very little information and no examples. Do any of you have any examples or can direct me to better documentation? Pyramid is just a WSGI application. This means it's dependent on the HTTP_HOST environ key (set by the Host header) to determine the host of the application. It's all relative. Point-being that Pyramid has no restrictions on what it can accept, thus the world is your oyster and you can set it up to