pylons

How do I restrict permissions based on the single page ID in the URL?

时间秒杀一切 提交于 2019-12-22 05:24:09
问题 I'm trying to implement Pyramid's Security features in my website but I'm having some trouble figuring out how to use it. I've been reading over this tutorial and this example, as well as the Pyramid docs, and I can't figure out how to implement an authorization policy for single page IDs. For example, I have the following URL scheme: /pages /pages/12 /pages obviously lists the available pages and /pages/:id is where you can read/comment on the page. The documentation/examples I've read have

Pylons authentication?

亡梦爱人 提交于 2019-12-22 04:48:18
问题 Is there a one and true way to add authentication in Pylons? I've seen so many different ways, but most of them are either outdated or too complex. Is there a tutorial somewhere that explains how to add authentication in a good and solid way? 回答1: Pylon's official stance appears to be: We don't do authentication, you can plug in whatever authentication system you want. Authkit works. It is very basic, but, does a relatively simple job rather well. Repoze.who/Repoze.what works fairly well and

Python pyramid - How to use checkboxes and radio buttons

痞子三分冷 提交于 2019-12-21 23:24:04
问题 I've been trying to make a form with checkboxes and radio button using Pyramid framework but I can't figure out how to do it properly. I'm using the pyramid_simpleform . So far I've been able to put my checkboxes on the form using a for loop but I can't make any checkbox checked even if I specify checked=True . % for item in groups: ${form.checkbox(name="groups",label=item, value=item, checked=True)} % endfor I know there's a better way of doing this. Is there any examples I could look at.

Searching across multiple tables (best practices)

主宰稳场 提交于 2019-12-21 21:43:18
问题 I have property management application consisting of tables: tenants landlords units properties vendors-contacts Basically I want one search field to search them all rather than having to select which category I am searching. Would this be an acceptable solution (technology wise?) Will searching across 5 tables be OK in the long run and not bog down the server? What's the best way of accomplishing this? Using PostgreSQL 回答1: I would suggest using a specialized full-text indexing tool like

Deploying Pylons with uWSGI

不羁的心 提交于 2019-12-21 17:14:37
问题 We're trying to move our intranet to Pylons. My boss is trying to set up Pylons to use uWSGI behind Apache so he can set up multiple, independent applications. However, he's having a difficult time getting it set up, with some apparent code problems in the C source code for uWSGI. Does anyone have any suggestions for how to deploy Pylons applications that might help us out? Thanks, Doug 回答1: Here is how I did it: http://tonylandis.com/python/deployment-howt-pylons-nginx-and-uwsgi/ 回答2: You

Strip whitespace from Mako template output (Pylons)

旧城冷巷雨未停 提交于 2019-12-21 04:52:12
问题 I'm using Mako + Pylons and I've noticed a horrendous amount of whitespace in my HTML output. How would I go about getting rid of it? Reddit manage to do it. 回答1: I'm not sure if there's a way to do it within Mako itself but you can always just do some post-rendering processing before you serve up the page. For example, say you have the following code that generates your horrendous whitespace: from mako import TemplateLookup template_lookup = TemplateLookup(directories=['.']) template =

Decorators vs. classes in python web development

孤人 提交于 2019-12-20 22:58:47
问题 I've noticed three main ways Python web frameworks deal request handing: decorators, controller classes with methods for individual requests, and request classes with methods for GET/POST. I'm curious about the virtues of these three approaches. Are there major advantages or disadvantages to any of these approaches? To fix ideas, here are three examples. Bottle uses decorators: @route('/') def index(): return 'Hello World!' Pylons uses controller classes: class HelloController(BaseController)

Ruby LESS gem equivalent in Python

╄→尐↘猪︶ㄣ 提交于 2019-12-20 10:41:27
问题 The Ruby LESS gem looks awesome - and I am working on a Python/Pylons web project where it would be highly useful. CSS is, as someone we're all familiar with recently wrote about, clunky in some important ways. So I'd like to make it easier on myself. Is there an existing Python module or library that provides parallel functionality? 回答1: I have need for a Python lesscss compiler too, so have started work on one here: http://code.google.com/p/lesscss-python/ Version 0.0.1 has been released,

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

…衆ロ難τιáo~ 提交于 2019-12-20 10:22:01
问题 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} I get the results by using """"views.py""" session = DBSession() row_data = session.query(Projects).filter_by(id=1).one() How can I get the column names from this result. PS: I am unable to use this method since I am using the declarative syntax. 回答1: The difference is between ORM and non-ORM, not

Should I use Pylons or Pyramid?

隐身守侯 提交于 2019-12-20 09:32:21
问题 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, and wonder if it is a to start for Pylons and Pyramid. 回答1: Pylons isn't being "cancelled", and it will continue to receive updates. That said, the "future" per se is in Pyramid. On the mailing list is has been referred to as Pylons 2.0. It is fully tested and better documented than Pylons 1.0,