pylons

Pylons and Memcached

主宰稳场 提交于 2019-12-03 15:14:19
问题 Anyone happen to use this combination in their web application? I'm having a bit of trouble finding some sort of tutorial or guideline for configuring this. Also seeing as how I started using Pylons recently I'm not familiar so please keep the advice very newbie friendly ( I haven't even used modules like Beaker all that much ). I'm using MySQL, running pastie HTTP server, just installed memcached package on Debian, using SQLAlchemy ORM to interact with my DB in my Pylons app, now I'm not

Strip whitespace from Mako template output (Pylons)

柔情痞子 提交于 2019-12-03 14:12:00
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. 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 = template_lookup.get_template("index.mako") whitespace_mess = template.render(somevar="no whitespace here") return

Pylons, SQlite and autoincrementing fields

人盡茶涼 提交于 2019-12-03 13:40:11
Hey! Just started working with Pylons in conjunction with SQLAlchemy, and my model looks something like this: from sqlalchemy import Column from sqlalchemy.types import Integer, String from helloworld.model.meta import Base class Person(Base): __tablename__ = "person" id = Column(Integer, primary_key=True) name = Column(String(100)) email = Column(String(100)) def __init__(self, name='', email=''): self.name = name self.email = email def __repr__(self): return "<Person('%s')" % self.name To avoid sqlite reusing id's that might have been deleted, I want to add AUTOINCREMENT to the column "id".

Schema qualified tables with SQLAlchemy, SQLite and Postgresql?

柔情痞子 提交于 2019-12-03 12:52:36
I have a Pylons project and a SQLAlchemy model that implements schema qualified tables: class Hockey(Base): __tablename__ = "hockey" __table_args__ = {'schema':'winter'} hockey_id = sa.Column(sa.types.Integer, sa.Sequence('score_id_seq', optional=True), primary_key=True) baseball_id = sa.Column(sa.types.Integer, sa.ForeignKey('summer.baseball.baseball_id')) This code works great with Postgresql but fails when using SQLite on table and foreign key names (due to SQLite's lack of schema support) sqlalchemy.exc.OperationalError: (OperationalError) unknown database "winter" 'PRAGMA "winter".table

Run Pylons controller as separate app?

我与影子孤独终老i 提交于 2019-12-03 11:51:32
I have a Pylons app where I would like to move some of the logic to a separate batch process. I've been running it under the main app for testing, but it is going to be doing a lot of work in the database, and I'd like it to be a separate process that will be running in the background constantly. The main pylons app will submit jobs into the database, and the new process will do the work requested in each job. How can I launch a controller as a stand alone script? I currently have: from warehouse2.controllers import importServer importServer.runServer(60) and in the controller file, but not

How can I redirect after POST in Pyramid?

拥有回忆 提交于 2019-12-03 08:40:53
问题 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 website.com/post Pyramid is giving me some troubles doing this. Here's my slimmed down views.py def _get_link_form(post_data): """ Returns the initialised form object """ return LinkForm(post_data) def home_page(request): form = _get_link_form(request.POST)

Random ids in sqlalchemy (pylons)

隐身守侯 提交于 2019-12-03 07:40:53
I'm using pylons and sqlalchemy and I was wondering how I could have some randoms ids as primary_key. the best way is to use randomly generated UUIDs: import uuid id = uuid.uuid4() uuid datatypes are available natively in some databases such as Postgresql (SQLAlchemy has a native PG uuid datatype for this purpose - in 0.5 its called sqlalchemy.databases.postgres.PGUuid ). You should also be able to store a uuid in any 16 byte CHAR field (though I haven't tried this specifically on MySQL or others). i use this pattern and it works pretty good. source from sqlalchemy import types from sqlalchemy

Decorators vs. classes in python web development

帅比萌擦擦* 提交于 2019-12-03 06:13:26
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): def index(self): return 'Hello World' Tornado uses request handler classes with methods for types:

Pylons FormEncode with an array of form elements

浪尽此生 提交于 2019-12-03 04:01:36
I have a Pylons app and am using FormEncode and HtmlFill to handle my forms. I have an array of text fields in my template (Mako) <tr> <td>Yardage</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]'

Pylons and Memcached

空扰寡人 提交于 2019-12-03 03:56:32
Anyone happen to use this combination in their web application? I'm having a bit of trouble finding some sort of tutorial or guideline for configuring this. Also seeing as how I started using Pylons recently I'm not familiar so please keep the advice very newbie friendly ( I haven't even used modules like Beaker all that much ). I'm using MySQL, running pastie HTTP server, just installed memcached package on Debian, using SQLAlchemy ORM to interact with my DB in my Pylons app, now I'm not sure what to do. memcached is nice and framework-agnostic, and you just have to write a bit of code to