pyramid

ajax widgets in pyramid and chameleon

可紊 提交于 2019-12-04 15:12:29
问题 I would like to be able to easily create ajax 'widgets' backed by chameleon and pyramid on the server side. Does Pyramid provide any plumbing code that would make writing widgets easy? My current approach is I have a home view which uses home.pt as the renderer. home.pt uses a macro base.pt which defines the page structure and provides a slot for home.pt to fill. base.pt also uses a login 'widget' macro that I have written (see: account_login_widget.pt below). In theory, this all sounds great

How to custom the deform Form?

泪湿孤枕 提交于 2019-12-04 14:33:08
When I use the default deform Form. It's not what I need. How to custom it ? For example, I need this: firstname:[_______] lastname:[_______] *username: [____________________] alink where [ _ _] represent normal html input. Should rewrite the template? This is a css issue, to provide a custom CSS class to a deform input you need to use the following: text_input = deform.widget.TextInputWidget( css_class='yourdivnamehere') Then inside deform you can: first_name = colander.SchemaNode(colander.String(), widget = text_input) 来源: https://stackoverflow.com/questions/20930864/how-to-custom-the-deform

Setup uWSGI as webserver with pyramid (no NGINX)

丶灬走出姿态 提交于 2019-12-04 14:20:40
问题 Most of the available tutorials show how to set up uWSGI with an upstream HTTP server (like NGINX). But uWSGI alone can act beautifully as router/proxy/load-balancer - refer this For my project, I didn't want to setup NGINX at this moment so I started off exploring the option of serving webpages through uWSGI. The answer here shows how to set it up with Pyramid . 回答1: I am using pyramid_mongodb scaffold, which I have modified to get it working on python3. See here for details. Assuming that

How to change the mako substitution delimiter characters?

走远了吗. 提交于 2019-12-04 14:12:05
Is it possible to change the "delimiter tags" for expression substitution in the Python Mako templating library? If so, how? e.g.: Instead of <div>${foobar}</div> , I would like to use the syntax <div>{{foobar}}</div> . I can't seem to find any references in the Mako docs . As of March 6, 2015, it's not currently possible . See the feature request to add configurable delimiters for Mako. 来源: https://stackoverflow.com/questions/28890953/how-to-change-the-mako-substitution-delimiter-characters

Want to prompt browser to save csv

帅比萌擦擦* 提交于 2019-12-04 14:01:25
问题 Want to prompt browser to save csv using pyramid.response.Response searched for clues and found here's a link Django answer but i can't use it with Pyramid wsgi my code looks like this: from pyramid.response import Response def get_list_names_emails(request): session, env = request.db, request.client_env response = Response(content_type='text/csv') output = StringIO() writer = csv.writer(output) writer.writerow(['SomeName', 'SomeEmail', 'CompanyName]) csv_output = output.getvalue() return csv

Python: AttributeError: _dep_map

不问归期 提交于 2019-12-04 12:59:57
I have an issue. I'm installing pyramid application on Ubuntu / Python 2.7 on virtual environment. I'm running setup.py as ../bin/python2.7 setup.py develop from root project directory and after: Traceback (most recent call last): File "setup.py", line 48, in <module> """, File "/usr/lib/python2.7/distutils/core.py", line 112, in setup _setup_distribution = dist = klass(attrs) File "/local/lib/python2.7/site-packages/setuptools/dist.py", line 269, in __init__ _Distribution.__init__(self,attrs) File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__ self.finalize_options() File "

How to integrate pystache with pyramid?

筅森魡賤 提交于 2019-12-04 12:08:59
I would like to use the class based views that pystache offers in my pyramid application, but I'm not entirely sure how to integrate the two properly. I've read this already, but it doesn't talk about using the class based views. How would I create a new renderer for pystache if I wanted to use class based views? Can somebody help me out here? Also, while I already know how mustache works, I can't seem to find much information on the python implementation (pystache). Can somebody point me in the right direction here? Implement a MustacheRendererFactory : class MustacheRendererFactory(object):

How do I get the number of rows affected with SQL Alchemy?

纵饮孤独 提交于 2019-12-04 11:34:10
How do I get the number of rows affected for an update statement with sqlalchemy? (I am using mysql and python/pyramid): from sqlalchemy.engine.base import ResultProxy @classmethod def myupdate(cls, id, myvalue): DBSession.query(cls).filter(cls.id == id).update({'mycolumn': myvalue}) if ResultProxy.rowcount == 1: return True else: return False Note: I saw this post but according to the docs : "The ‘rowcount’ reports the number of rows matched by the WHERE criterion of an UPDATE or DELETE statement."....in other words, it doesn't return the number of rows affected by the update or delete

No module named deploy when trying to start pyramid app with mod_wsgi

谁都会走 提交于 2019-12-04 10:51:25
trying to use mod_wsgi for the first time for my pyramid app, but I keep getting an ImportError: No module named deploy when I try to access the site in my /etc/apache2/sites-available/domain.com <VirtualHost *:80> ServerName domain.com ServerAlias www.domain.com ServerAdmin admin@domain.com DocumentRoot /data/app ErrorLog /data/app/apache_error.log WSGIApplicationGroup %{GLOBAL} WSGIPassAuthorization On WSGIDaemonProcess pyramid user=www-data group=www-data \ processes=2 threads=4 \ python-path=/data/app/lib/python2.6/site-packages/ WSGIScriptAlias / /data/app/pyramid.wsgi <Directory /data

Pyramid resource: In plain English

两盒软妹~` 提交于 2019-12-04 10:45:34
问题 I've been reading on the ways to implement authorization (and authentication) to my newly created Pyramid application. I keep bumping into the concept called "Resource". I am using python-couchdb in my application and not using RDBMS at all, hence no SQLAlchemy. If I create a Product object like so: class Product(mapping.Document): item = mapping.TextField() name = mapping.TextField() sizes = mapping.ListField() Can someone please tell me if this is also called the resource? I've been reading