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.

Filter by
Sorted by
Tagged with
143 votes
15 answers
150k views

SQLAlchemy - Getting a list of tables

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.
  • 2,723
72 votes
8 answers
126k views

How to get column names from SQLAlchemy result (declarative syntax)

I am working in a pyramid project and I've the table in SQLAlchemy in declarative syntax """models.py""" class Projects(Base): __tablename__ = 'projects' __table_args__ = {'autoload': True} ...
  • 3,432
62 votes
10 answers
44k views

SQLAlchemy cannot find a class name

Simplified, I have the following class structure (in a single file): Base = declarative_base() class Item(Base): __tablename__ = 'item' id = Column(BigInteger, primary_key=True) # ... ...
  • 45.4k
53 votes
5 answers
57k views

sqlalchemy existing database query

I am using SQLAlchemy as ORM for a python project. I have created few models/schema and it is working fine. Now I need to query a existing MySQL database, no insert/update just the select statement. ...
  • 6,695
52 votes
5 answers
81k views

SQLAlchemy boolean value is None

I have this table in my Pyramid app class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) ..... is_active = Column(Boolean, unique=False) def __init__(...
  • 3,183
49 votes
3 answers
18k views

Should I use Pylons or Pyramid?

I was planning to move from Django to Pylons, but then I bumped into Pyramid. What are the differences between Pylons and Pyramid? I read some text in PylonsBook, which currently covers Pylons 0.9.7,...
  • 753
45 votes
3 answers
24k views

Make sure only one worker launches the apscheduler event in a pyramid web app running multiple workers

We have a web app made with pyramid and served through gunicorn+nginx. It works with 8 worker threads/processes We needed to jobs, we have chosen apscheduler. here is how we launch it from apscheduler....
43 votes
1 answer
25k views

ArgumentError: relationship expects a class or mapper argument

I am getting this strange error, and I'm saying strange because I made a change to an unrelated table. I am trying to query my tDevice table which looks like this: class TDevice(Base): ...
  • 3,819
42 votes
1 answer
12k views

User Authentication in Pyramid

I'm building a webapp and needed to choose between Django and Pyramid. I decided to go with Pyramid. I understand Pyramid comes with its own authentication/authorization framework which looks nice. ...
  • 5,890
34 votes
4 answers
34k views

get table columns from sqlAlchemy table model

I have a table where I would like to fetch all the column names however after browsing the interwebs I could not find a way that works. This is what my table looks like: class myTable(Base): ...
  • 3,819
26 votes
2 answers
8k views

What does '@reify' do and when should it be used?

I saw it in the Pyramid tutorial for UX design. I couldn't make out much what this decorator is all about. Sample code where I saw its usage. def __init__(self, request): self.request = request ...
25 votes
9 answers
25k views

uWSGI Fails with No module named encoding Error

I am trying to setup uWSGI with Pyramid, but I am getting this error, when attempting uwsgi --ini-paste development.ini Python version: 3.2.3 Error message: uwsgi socket 0 bound to UNIX address /...
  • 1,133
24 votes
3 answers
10k views

Is Pyramid ready/recommended for prime time? [closed]

I was wandering around testing various options for my new personal project, ranging from PHP, to node.js, to Haskell. I feel most comfortable with Python, though, so I thought I'd go back to it in the ...
user avatar
21 votes
3 answers
9k views

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 "...
  • 1,475
20 votes
4 answers
8k views

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 ...
  • 7,607
20 votes
6 answers
23k views

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 ...
  • 24.1k
20 votes
1 answer
10k views

When should I be calling flush() on SQLAlchemy?

I'm new to SQLAlchemy and have inherited a somewhat messy codebase without access to the original author. The code is litered with calls to DBSession.flush(), seemingly any time the author wanted to ...
  • 878
20 votes
2 answers
26k views

AttributeError: 'InstrumentedList' object has no attribute

I have these tables tables: class Thing(Base): __tablename__ = 'thing' id = Column(Integer, primary_key=True) class User(Base): __tablename__ = 'user' id = Column(Integer, ...
  • 19.5k
20 votes
1 answer
17k views

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: <html>{% include "content.html" %}</html> content....
  • 2,085
19 votes
1 answer
5k views

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 ...
  • 32.7k
19 votes
6 answers
20k views

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....
  • 7,607
18 votes
4 answers
5k views

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 ...
  • 3,966
18 votes
2 answers
3k views

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 ...
  • 7,856
18 votes
1 answer
8k views

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 ...
  • 41k
17 votes
2 answers
4k views

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 ...
  • 173
16 votes
2 answers
7k views

Pyramids route_url with additional query arguments

In Pyramids framework, functions route_path and route_url are used to generate urls from routes configuration. So, if I have route: config.add_route('idea', 'ideas/{idea}') I am able to generate the ...
  • 6,724
16 votes
3 answers
9k views

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) { ...
  • 3,549
16 votes
6 answers
8k views

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 ...
  • 5,843
16 votes
3 answers
15k views

Using a different schema for the same declarative Base in sqlalchemy

I am new to both Pyramid and SQLAlchemy. I am working on a Python Pyramid project with SQLAlchemy. I have a simple model set up below. How would I go about being able to use this with different ...
16 votes
4 answers
5k views

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, ...
15 votes
4 answers
18k views

`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 "<stdin>", line 1, in <...
  • 2,634
15 votes
3 answers
6k views

Getting the request IP address with Pyramid

I'm using Pyramid framework and I want to access the IP address from which the request originated. I assume it's in the request object (passed to every view function) somewhere, but I can't find ...
  • 7,766
15 votes
5 answers
9k views

Pyramid CORS for Ajax requests

Is it possible automatically add Access-Control-Allow-Origin header to all responses which was initiated by ajax request (with header X-Requested-With) in Pyramid?
  • 2,184
15 votes
1 answer
26k views

Validation in SQLAlchemy

How can I get the required validator in SQLAlchemy? Actually I just wanna be confident the user filled all required field in a form. I use PostgreSQL, but it doesn't make sense, since the tables ...
  • 1,253
15 votes
3 answers
9k views

how can i get the ini data in pyramid?

There is a development.ini or production.ini in a pyramid project. I add my own config data in the ini files like: [thrift] host = 0.0.0.0 port = 8080 and I want to use the config data in one of py ...
  • 1,811
15 votes
1 answer
5k views

Pyramid and .ini configuration

Each Pyramid application has an associated .ini file that contains its settings. For example, a default might look like: [app:main] use = egg:MyProject pyramid.reload_templates = true pyramid....
  • 2,524
15 votes
1 answer
11k views

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) ...
  • 3,118
15 votes
2 answers
9k views

SQLAlchemy StaleDataError on deleting items inserted via ORM sqlalchemy.orm.exc.StaleDataError

I'm having an issue where I get a an error such as this one: "MyPyramidApplication Error"<class 'sqlalchemy.orm.exc.StaleDataError'>: DELETE statement on table 'page_view' expected to delete 6 ...
  • 2,525
15 votes
3 answers
5k views

SQLAlchemy logging of changes with date and user

This is very similar to another question that's over 3 years old: What's a good general way to look SQLAlchemy transactions, complete with authenticated user, etc? I'm working on an application ...
  • 9,397
14 votes
4 answers
18k views

Detaching SQLAlchemy instance so no refresh happens

I want to detach an instance of a class from my session but it should still be available for reading (without emitting a query). I have been scanning through the documentation for days now, but every ...
  • 6,825
14 votes
3 answers
4k views

In the Pyramid web framework, how do I source sensitive settings into development.ini / production.ini from an external file?

I'd like to keep development.ini and production.ini under version control, but for security reason would not want the sqlalchemy.url connection string to be stored, as this would contain the username ...
  • 9,038
14 votes
2 answers
6k views

Use different .ini file for alembic.ini

I'm attempting to configure SQLAlchemy Alembic for my Pyramid project and I want to use my developement.ini (or production.ini) for the configuration settings for Alembic. Is it possible to specify ...
14 votes
2 answers
3k views

Multiple domains and subdomains on a single Pyramid instance

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 ...
  • 19.5k
14 votes
2 answers
4k views

pyramid pserve server as https

Is it possible to run Pyramid's pserve such that it starts an https server (for example https://0.0.0.0:6543)? I would like to gear up my application for https locally if possible.
  • 8,238
14 votes
6 answers
3k views

Equivalent of template context in Pyramid (pylons user)

What is the equivalent of template context in Pyramid? Does the IBeforeRender event in pyramid have anything to with this? I've gone through the official documentation but diffcult to understand what ...
  • 2,723
14 votes
3 answers
12k views

How to find the cause of "task queue depth" warnings from waitress?

Is there a recommended way to diagnose the cause of task queue depth warnings like the one below from waitress? Perhaps there is some way to log queued tasks / requests? 2019-04-25 14:45:23,048 ...
  • 14k
14 votes
1 answer
4k views

Help improve my file upload method (Pyramid framework)

Currently, I am using the following method for uploading files (via HTML form) in Pyramid. if request.params.get('form.submitted'): upload_directory = os.getcwd() + '/myapp/static/uploads/' ...
  • 2,723
14 votes
2 answers
9k views

Transaction manager revert/rollback last commit

I try to speedup my tests by putting test data from test case setUp() to setUpClass()/teardownClass class method, so it does not recreate same select only fixture for every test in test case. @...
  • 2,044
13 votes
3 answers
9k views

SQLAlchemy - condition on join fails with AttributeError: Neither 'BinaryExpression' object nor 'Comparator' object has an attribute 'selectable'

I'm running SQLAlchemy with Pyramid. I'm trying to run a query with a custom 'join' condition : DBSession.query(A)\ .outerjoin(A.b, B.a_id == A.id)\ .all() however the query fails ...
  • 3,739
13 votes
4 answers
10k views

PyCharm SQLAlchemy autocomplete

I started evaluating PyCharm 3 professional edition because I will be working on several Pyramid + SQLAlchemy projects. One of the things I would really love to have is SQLAlchemy autocomplete. I ...

1
2 3 4 5
45