pyramid

SelectField in wtforms and added <option> via javascript

只谈情不闲聊 提交于 2019-12-21 00:51:11
问题 I'm currently work on some project in pyramid and have problem with wtforms SelectField. I have a 3 SelectField fields: car_make (e.g., "audi") car_model (e.g., "audi 80") car_version (e.g., "AUDI 80 B4"). The car_make choices I can load in the view. The choices for rest of SelectFields (car_model, car_version) I will load on the client side via AJAX/javascript (I can choose car_model when car_make is selected and so on). The problem is that when I submit the form, car_model and car_version

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,

In Pyramid, how do I return raw HTML from a view?

删除回忆录丶 提交于 2019-12-20 04:05:53
问题 I'm really new to Pyramid (and pretty new to web frameworks in general). I'm trying to get to the stage where I can return raw HTML from a view, so that I can markup data returned from my mongoDB store. My __init__.py in my pyramid project is standard: def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(root_factory = Root, settings = settings) config.add_view('hermesweb.views.my_view', context = 'hermesweb:resources.Root',

In Pyramid, how do I return raw HTML from a view?

梦想的初衷 提交于 2019-12-20 04:05:33
问题 I'm really new to Pyramid (and pretty new to web frameworks in general). I'm trying to get to the stage where I can return raw HTML from a view, so that I can markup data returned from my mongoDB store. My __init__.py in my pyramid project is standard: def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(root_factory = Root, settings = settings) config.add_view('hermesweb.views.my_view', context = 'hermesweb:resources.Root',

Python Pyramid & Chameleon templating language escapes html

梦想的初衷 提交于 2019-12-19 09:24:14
问题 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? 回答1: Chameleon is based on the Zope Page Templates library, so if you find the

HTML form name array parsing in Pyramid (Python)

纵然是瞬间 提交于 2019-12-19 09:24:02
问题 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!

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

安稳与你 提交于 2019-12-19 04:14:25
问题 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

In Pyramid, how can I use a different renderer based on contents of context?

可紊 提交于 2019-12-19 02:31:20
问题 I have 3 different product page layouts that I would like to display dependent on the information available about the products. Using traversal I have a class called ProductFinder that grabs all the information. For example the user goes to domain/green/small and ProductFinder will list all products from my DB that are green and small. This list is self.products in the ProductFinder class. In my __init__.py I have added the line: config.add_view('app.views.products', name='') In products.py I

Gzipping all HTTP traffic with Pyramid

荒凉一梦 提交于 2019-12-18 14:53:58
问题 I am creating a mobile service based on Pyramid framework. Because it's mobile everything to reduce bandwidth usage is plus. I am considering gzipping all the traffic, even dynamic HTML pages. What kind of hooks Pyramid framework provides for this? Or is there WSGI middleware for the task? I'd like to do this still on Python level, not Nginx/Apache, so I can better statistics how much gzip brings benefirts. 回答1: First of all I should stress that you should do this on the web server level