pyramid

Easy way to switch between renderers within the same view method

冷暖自知 提交于 2019-12-01 11:31:20
I set up my function like this @view_config( route_name = 'route_name', permissions = 'permissions', renderer = 'r.mako' ) def r( request ): # stuff goes here now, I want to add functionality such that I check certain conditions (using ajax) i would use one template, otherwise use another. is there a way to do this in pyramid? thanks Well you can add the view multiple times with different renderers if you can determine what you want to do via predicates. For example @view_config(route_name='route', xhr=True, renderer='json') @view_config(route_name='route', renderer='r.mako') @view_config

Which one is the correct approach for form validation ? Colander's Schema validation or Deform's form validation?

梦想与她 提交于 2019-12-01 11:20:26
I have just started using Pyramid for one of my projects and I have a case where in I need to validate a form field input, by taking that form field value and making a web-service call to assert the value's correctness. Like for example there is a field called your bank's CUSTOMER-ID. I need to take that(alone) as input and validate at the server level by making a web-service call (like http://someotherdomain/validate_customer_id/?customer_id=<input_value> )lets say. I am using Colander for form schema management and Deform for all form validation logic. I am confused about where I need to

HTML form name array parsing in Pyramid (Python)

穿精又带淫゛_ 提交于 2019-12-01 10:38:21
Is there any way for Pyramid to process HTML form input which looks like this: <input type="text" name="someinput[]" value="" /> or even more usefully: <input type="text" name="someinput[0][subelement1]" value="" /> <input type="text" name="someinput[0][subelement2]" value="" /> <input type="text" name="someinput[1][subelement1]" value="" /> <input type="text" name="someinput[1][subelement2]" value="" /> ...and access that data easily (e.g. via a dict)? Any help would be much appreciated! EDIT: to make it clearer, what I need is the ability to have a form where a user can add as many

Which one is the correct approach for form validation ? Colander's Schema validation or Deform's form validation?

孤街醉人 提交于 2019-12-01 09:16:51
问题 I have just started using Pyramid for one of my projects and I have a case where in I need to validate a form field input, by taking that form field value and making a web-service call to assert the value's correctness. Like for example there is a field called your bank's CUSTOMER-ID. I need to take that(alone) as input and validate at the server level by making a web-service call (like http://someotherdomain/validate_customer_id/?customer_id=<input_value> )lets say. I am using Colander for

Python Pyramid & Chameleon templating language escapes html

☆樱花仙子☆ 提交于 2019-12-01 08:03:37
I can't make sense of chameleon's tags. I'm a django user, but decided to introduce my CompSci course mates and myself to Pyramid, since I though more lightweight = easier to learn. At the moment the ${} tag is escaping any html tags I'm trying to output through it. In django there was some way to specify that a variable is "safe" and doesn't need to be escaped. How can I do the same thing in Pyramid / Chameleon? Chameleon is based on the Zope Page Templates library, so if you find the Chameleon documentation lacking, you might wish to check out the zpt docs. In any case, there are two main

I can not connect to https waitress wsgi server

ε祈祈猫儿з 提交于 2019-12-01 06:23:13
I have tried the tutorial of python pyramid framework but, https connection, no matter how able to waitress. http://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki2/installation.html If you look at the documents of waitress, there is an item called 'url_scheme' in pasteDeploy format. I tried to add the following to development.ini: # # # # Wsgi server configuration # # # [server: main] use = egg:waitress#main host = 0.0.0.0 port = 6543 url_scheme = https But, it seems to be listening for http connections be performed pserve command. $ serve development.ini - reload Starting

AttributeError: 'InstrumentedList' object has no attribute

感情迁移 提交于 2019-12-01 03:42:25
I have these tables tables: class Thing(Base): __tablename__ = 'thing' id = Column(Integer, primary_key=True) class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) class Voteinfo(Base): __tablename__ = 'voteinfo' thing_id = Column(Integer, ForeignKey('thing.id'), primary_key=True) thing = relationship('Thing', backref='voteinfo') upvotes = Column(Integer) downvotes = Column(Integer) def __init__(self, thing) self.thing = thing class VoteThing(Base): __tablename__ = 'votething' id = Column(Integer, primary_key=True) voter_id = Column(Integer, ForeignKey('voter.id'))

AttributeError: 'InstrumentedList' object has no attribute

流过昼夜 提交于 2019-12-01 00:45:12
问题 I have these tables tables: class Thing(Base): __tablename__ = 'thing' id = Column(Integer, primary_key=True) class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) class Voteinfo(Base): __tablename__ = 'voteinfo' thing_id = Column(Integer, ForeignKey('thing.id'), primary_key=True) thing = relationship('Thing', backref='voteinfo') upvotes = Column(Integer) downvotes = Column(Integer) def __init__(self, thing) self.thing = thing class VoteThing(Base): __tablename__ =

Insert binary file into MSSQL db (varbinary) with python pymssql

橙三吉。 提交于 2019-12-01 00:42:04
I'm trying to insert binary data into an MSSQL database using stored procedures from within an pyramid web application using pymssql. The MSSQL datatype for the respective column is varbinary(max) . My question is: What does the varbinary datatype of the MSSQL database expect me to do with the binary file before inserting it? Here's what I've been trying: with open(tmp_file, 'rb') as content_file: filecontent = content_file.read() ... and then pass the value of filecontent to the stored procedure. tmp_file in this case is a valid path to a .png file. The MSSQL db answers with the following

Static files for Pyramid Application on Elastic Beanstalk

依然范特西╮ 提交于 2019-11-30 22:56:15
I'm trying to serve some static css, png's, etc. from my Pyramid app that's hosted on Elastic Beanstalk. It works fine on my local machine but when I try to run on EB, neither the CSS nor the images are found. Here's the relevant code: From .ebextensions: option_settings: aws:elasticbeanstalk:container:python: WSGIPath: pyramid.wsgi aws:elasticbeanstalk:application: Application Healthcheck URL: /health aws:elasticbeanstalk:container:python:staticfiles: "/static/": "static/" From home.make <link rel="stylesheet" href="/static/css/settings/globals.css"/> <link rel="stylesheet" href="/static/css