pyramid

SQLAlchemy, Serializable transactions isolation and retries in idiomatic Python way

帅比萌擦擦* 提交于 2020-01-02 04:04:22
问题 PostgreSQL and SQL defines a Serializable transaction isolation level. If you isolate transactions to this level, conflicting concurrent transactions abort and need retrying. I am familiar with the concept of transaction retries from Plone / Zope world where the entire HTTP request can be replayed in the case there is a transaction conflict. How similar functionality could be achieved with SQLAlchemy (and potentially with zope.sqlalchemy)? I tried to read the documentation of zope.sqlalchemy

using list on postgresql JSON type with sqlalchemy

荒凉一梦 提交于 2020-01-02 02:02:26
问题 I am using pyramid with sqlalchemy, pyramid_tm and postgresql to test this. DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) Base = declarative_base() class MyList(Base): id = Column(Integer, primary_key=True) lst = Column(JSON) I am using postgresql 9.3+ and using JSON type. When i do this mylst = MyList(lst=[]) i can see empty [] list being created on database as well, and def view(request): mylst = DBSession.query(MyList).get(1) mylst.lst.append('45') print

how to use macros with pyramid / ZPT (Chameleon)

℡╲_俬逩灬. 提交于 2020-01-01 06:38:08
问题 I want to use macros with pyramid+ZPT engine (Chameleon). The docs say that "A single Page Template can accommodate multiple macros." http://chameleon.readthedocs.org/en/latest/reference.html#macros-metal Thus I defined a file macros.pt : <div metal:define-macro="step-0"> <p>This is step 0</p> </div> <div metal:define-macro="step-1"> <p>This is step 1</p> </div> and a global template main_template.pt with all the html stuff defining a slot content . and a template for my view progress.pt

Pyramid.security: Is getting user info from a database with unauthenticated_userid(request) really secure?

不羁的心 提交于 2020-01-01 05:41:07
问题 I'm trying to make an accesible cache of user data using Pyramid doc's "Making A “User Object” Available as a Request Attribute" example. They're using this code to return a user object to set_request_property: from pyramid.security import unauthenticated_userid def get_user(request): # the below line is just an example, use your own method of # accessing a database connection here (this could even be another # request property such as request.db, implemented using this same # pattern).

pyramid AuthTktAuthenticationPolicy secret parameter

。_饼干妹妹 提交于 2019-12-30 09:54:28
问题 What exactly is the 'secret' parameter of Pyramid's pyramid.authentication.AuthTktAuthenticationPolicy function? The documentation says that it's "(a string) used for auth_tkt cookie signing. Required." The tutorial says that it's "is a string representing an encryption key used by the 'authentication ticket' machinery represented by this policy". What is auth_tkt cookie signing? What is this 'authentication ticket' machinery? Is this secret supposed to be something I store as a hash in a

I can not connect to https waitress wsgi server

天大地大妈咪最大 提交于 2019-12-30 09:35:59
问题 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

Storing and validating encrypted password for login in Pyramid

。_饼干妹妹 提交于 2019-12-30 06:50:12
问题 I am trying to validate an encrypted password for login purposes in Pyramid. So that if the user and password match then the system will authorize the user. At the moment I am finding it difficult to write a function to compare passwords when one is encrypted in the database and the the password being entered into Pyramid's login form is unencrypted. Right now, I have no verification occurring in the login view. I am new to this entire process of working with security measures/code and want

How to use template inheritance with Chameleon?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 05:21:05
问题 I am using latest Pyramid to build a web app. Somehow we have started using Chameleon as the template engine. I have used Mako before and it was extremely simple to create a base template. Is this possible with chameleon as well? I have tried to look through the docs but I can not seem to find an easy solution. 回答1: With Chameleon >= 2.7.0 you can use the "load" TALES expression. Example: main.pt: <html> <head> <div metal:define-slot="head"></div> </head> <body> <ul id="menu"> <li><a href=""

Syntax error in a Python library, and I'm not sure how to proceed

岁酱吖の 提交于 2019-12-25 10:52:29
问题 I'm using pyramid 1.5.1 and python 3.2, and I just added quite a bit of code and a couple libraries to my project. On running development.ini, I'm getting the error below. If I had to take a wild guess, I would say that this particular library (looks like Markupsafe?) isn't compatible with Python3...but the project page seems to indicate that it is. Problem is, I'm not calling this library directly, it's being used by another library that would be very difficult to replace. I'm new to Python

Syntax error in a Python library, and I'm not sure how to proceed

点点圈 提交于 2019-12-25 10:52:09
问题 I'm using pyramid 1.5.1 and python 3.2, and I just added quite a bit of code and a couple libraries to my project. On running development.ini, I'm getting the error below. If I had to take a wild guess, I would say that this particular library (looks like Markupsafe?) isn't compatible with Python3...but the project page seems to indicate that it is. Problem is, I'm not calling this library directly, it's being used by another library that would be very difficult to replace. I'm new to Python