pyramid

IntegrityError: ERROR: null value in column “user_id” violates not-null constraint

喜夏-厌秋 提交于 2019-12-06 07:50:52
Using: postgres (PostgreSQL) 9.4.5 I just migrated a sqlite3 db onto a postgresql db. For some reason since this migration, when I try to create a user, an error regarding the user_id (which is a primary key) is being raised. This was not an issue before with sqlite3 . I have spent time looking through the docs and stack questions, but remain confused. Inside api.create_user() : api.create_user(username ='lola ', firstname ='cats ', lastname ='lcatk', email='cags@falc.com') sqlalchemy db Model: class User(Base): __tablename__ = 'users' #user_id = Column(Integer, primary_key=True) #changed to:

template not found, deploying Pyramid on Webfaction

不打扰是莪最后的温柔 提交于 2019-12-06 07:35:14
I'm trying to deploy my webapp to Webfaction, the basic example is working correctly, I got a TemplateNotFound in a template that extends a basic template using Jinja2. Here is my project tree: /webapps /myapp development.ini production.ini /bin /theapp /Project setup.py /project __init__.py views.py /templates base.jinja2 home.jinja2 /static _ init _.py config.include('pyramid_jinja2') config.add_jinja2_search_path("templates") home.jinja2 {% extends "templates/base.jinja2" %} To be more clear, the project works locally I know it's something with the template path, I'm not sure how to set it,

Translating %% with gettext and jinja2 and pyramid

六月ゝ 毕业季﹏ 提交于 2019-12-06 07:21:29
Doing i18n work with Python using Jinja2 and Pyramid. Seems to have a problem knowing how it should translate %%. I'm beginning to suspect the bug is in Jinja2. So I've done some more investigation and it appears the problem is more with gettext than with jinja2 as illustrated with the repl >>>gettext.gettext("98%% off %s sale") % ('holiday') '98% off holiday sale' >>>gettext.gettext("98%% off sale") '98%% off sale' >>>gettext.gettext("98% off %s sale") % ('holiday') Traceback (most recent call last): Python Shell, prompt 13, line 1 TypeError: %o format: a number is required, not str It seems

Python: AttributeError: _dep_map

谁说胖子不能爱 提交于 2019-12-06 07:18:04
问题 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

Can't send emails with pyramid_mailer and gmail

拟墨画扇 提交于 2019-12-06 07:12:28
问题 I am trying to send emails from my pyramid website with my gmail smtp and the pyramid_mailer package. First of all, if anyone has another suggestion for an email solution, please let me know! I added the following to my dev.ini: mail.host = smtp.gmail.com mail.username = user@gmail.com mail.password = password mail.port = 465 mail.ssl = True And then I'm sending the message like so: config.registry['mailer'] = Mailer.from_settings(settings) and later... mailer = request.registry['mailer']

How to custom the deform Form?

空扰寡人 提交于 2019-12-06 07:01:25
问题 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? 回答1: 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

How to integrate pystache with pyramid?

吃可爱长大的小学妹 提交于 2019-12-06 06:31:34
问题 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

Validation in SQLAlchemy

这一生的挚爱 提交于 2019-12-06 06:18:32
问题 How can I get the required validator in SQLAlchemy? Actually I just wanna be confident the user filled all required field in a form. I use PostgreSQL, but it doesn't make sense, since the tables created from Objects in my models.py file: from sqlalchemy import ( Column, Integer, Text, DateTime, ) from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import ( scoped_session, sessionmaker, ) from zope.sqlalchemy import ZopeTransactionExtension from pyramid.security import

SQLAlchemy: Knowing the field names and values of a model object?

淺唱寂寞╮ 提交于 2019-12-06 06:01:59
问题 I'm trying to keep to SOLID object oriented programming principles, stay DRY, etc, but my newness to Python/SQLAlchemy/Pyramid is making it very hard. I'm trying to take what I now know to be a SQLAlchemy model used to create a simple Pyramid Framework object and use what I know to be "reflection" in C#, it may be called something different in Python (Introspection? Not sure as this is only my second week with python but I have lots of experience in other languages (C/C++/C#,Java, etc) so the

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

纵饮孤独 提交于 2019-12-06 05:50:18
问题 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