Questions tagged [pyramid]

Pyramid is a Python-based web framework provided by the Pylons Project. Do not use the "pyramid" tag for displaying items in a pyramid shape.

Pyramid is a small, fast, down-to-earth Python web application development framework that is un-opinionated and very flexible. This allows it to be used in a variety of different projects where Pyramid's flexibility allows for easier integration with already-existing code/modules. Because it is un-opinionated it gives the developer a lot of choice in how to handle various aspects - such as sessions, authentication, authorization and more - without sacrificing support for those aspects or out-of-box ease of use.

It is developed as part of The Pylons Project. It is licensed under a BSD-like license with extra clauses.

Official Logo

Official Pyramid Logo

Official Icon

Official Pyramid Icon

2212 questions
21
votes
3 answers

How to get Registry().settings during Pyramid app startup time?

I am used to develop web applications on Django and gunicorn. In case of Django, any application modules in a Django application can get deployment settings through django.conf.settings. The "settings.py" is written in Python, so that any arbitrary…
takaomag
  • 1,545
  • 1
  • 16
  • 26
21
votes
1 answer

Why does PIP convert underscores to dashes

I am trying to install a Pyramid app -- let's say test_app. inside a virtual environment and it is getting installed as test-app (pip freeze output shows it test-app==0.0). Because of this, I can not import the package. How should I fix this…
treecoder
  • 43,129
  • 22
  • 67
  • 91
20
votes
1 answer

Jinja2 Inheritance with Blocks and Includes

I can't figure out how to modify blocks from included templates using Jinja2. Here's an example where I use three files. base.html: {% include "content.html" %} content.html:

{% block title %}Title{% endblock title%}

{%…
Devin
  • 2,113
  • 2
  • 22
  • 28
20
votes
6 answers

`UnencryptedCookieSessionFactoryConfig` error when importing Apex

I'm trying to use Apex and whenever I try to import it (or anything involving it) I get the following traceback: Traceback (most recent call last): File "", line 1, in File…
Sean
  • 2,890
  • 8
  • 36
  • 78
20
votes
4 answers

Is there a better way to switch between HTML and JSON output in Pyramid?

# /test{.format} no longer seems to work... config.add_route('test', '/test.{ext}', view='ms.views.test') views.py: from pyramid.response import Response from pyramid.renderers import render import json def test(request): extension =…
dave
  • 7,717
  • 19
  • 68
  • 100
20
votes
6 answers

Trying to catch integrity error with SQLAlchemy

I'm having problems with trying to catch an error. I'm using Pyramid/SQLAlchemy and made a sign up form with email as the primary key. The problem is when a duplicate email is entered it raises a IntegrityError, so I'm trying to catch that error…
Lostsoul
  • 25,013
  • 48
  • 144
  • 239
19
votes
1 answer

Pyramid authorization for stored items

I'm trying to create an authorization policy that takes "item" ownership into account. For example some user X "owns" items A, B, C. Those are accessed via URLs like /item/{item}/some_options. How can I get the information about {item} to the…
viraptor
  • 33,322
  • 10
  • 107
  • 191
19
votes
6 answers

How can I redirect after POST in Pyramid?

I'm trying to have my form submit to a route which will validate the data then redirect back to the original route. For example: User loads the page website.com/post Form POSTs the data to website.com/post-save User gets redirected back to…
dave
  • 7,717
  • 19
  • 68
  • 100
19
votes
1 answer

How do I return results from both tables in a SQLAlchemy JOIN?

I have two tables defined in my ORM as: Base = declarative_base() class GeneralLedger(Base): __tablename__ = 'generalledgers' id = Column(Integer, primary_key=True) invoiceId = Column(Integer) .. class ConsolidatedLedger(Base): …
ericso
  • 3,218
  • 7
  • 29
  • 36
18
votes
4 answers

Pyramid: Custom 404 page returns as "200 OK"

I have a custom 404 view defined in my Pyramid app: @view_config(context=HTTPNotFound, renderer='404.pt') def not_found(self, request): return {} It works fine, except that the HTTP status code sent with the content is 200 OK, which is not OK…
Theron Luhn
  • 3,974
  • 4
  • 37
  • 49
18
votes
2 answers

Pyramid REST API: How do I handle concurrent data access safely?

I am working on a REST API for a web service using Pyramid and Cornice; data on the server side is handled using SQLAlchemy and MySQL. The web server is nginx using uwsgi, and it's configured to run multiple Python processes: [uwsgi] socket =…
Jens
  • 8,423
  • 9
  • 58
  • 78
17
votes
2 answers

Pyramid project structure

I am developing a rather big project in pyramid. I used django before. I really like the way it structures the project and encapsulate functionality into apps. I would like to achieve same structure with pyramid. I know pyramid is very flexible…
udaycode
  • 173
  • 1
  • 5
16
votes
6 answers

Calling another view in Pyramid

My goal: In Pyramid, to call another view-callable, and to get a Response object back without knowing any details about that view-callable. In my Pyramid application, say I have a view "foo" which is defined using a view_config…
kes
  • 5,983
  • 8
  • 41
  • 69
16
votes
3 answers

In pyramid how to return 400 response with json data?

I have the following jquery code: $.ajax({ type: 'POST', url: url, data: data, dataType: 'json', statusCode: { 200: function (data, textStatus, jqXHR) { console.log(data); }, 201:…
Marconi
  • 3,601
  • 4
  • 46
  • 72
16
votes
4 answers

Pyramid: simpleform or deform?

For a new (Python) web application with the Pyramid web framework, I'd like to use a form binding and validation library and so far found simpleform and deform. Does anyone have experience with these, and can tell me why I should pick one or the…
Jasper van den Bosch
  • 3,169
  • 4
  • 32
  • 55