pyramid

Why is SQLAlchemy execute Update not working

人走茶凉 提交于 2019-12-12 09:14:12
问题 I have the following: @periodic_task(run_every=crontab(minute="*/1")) def PeriodicUpdateAgentLastRica(): query = """update agents inner join (select sims.consignment_agents_id as agents_id, MAX(sims.rica_current_stamp) as last_rica_stamp from sims where sims.rica_current_stamp > DATE_SUB(now(), INTERVAL 3 MONTH) and sims.consignment_agents_id is not NULL group by sims.consignment_agents_id) as dt on dt.agents_id = agents.id set agents.last_rica_stamp = dt.last_rica_stamp""" res = Session

How can I serve temporary files from Python Pyramid

岁酱吖の 提交于 2019-12-12 07:15:06
问题 Currently, I'm just serving files like this: # view callable def export(request): response = Response(content_type='application/csv') # use datetime in filename to avoid collisions f = open('/temp/XML_Export_%s.xml' % datetime.now(), 'r') # this is where I usually put stuff in the file response.app_iter = f response.headers['Content-Disposition'] = ("attachment; filename=Export.xml") return response The problem with this is that I can't close or, even better, delete the file after the

Search a Set in SQLAlchemy query

末鹿安然 提交于 2019-12-12 06:40:11
问题 I have 2 databases in completely different servers with no relationship between the two. There's one column in both databases that has identical data. I need to match based on that data so I can grab other info from both databases in one View. Here's what I've got in my views.py @view_config(route_name='cis', renderer='templates/cis.pt') def cis(request): db1 = cis_db.query(site.site_id).join(site_tag).filter(site_tag.tag_id.like(202)).all() db2 = DBSession.query(A_School.cis_site_id).all()

Pyramid with reCaptcha: how to implement?

╄→гoц情女王★ 提交于 2019-12-12 02:55:14
问题 I want to add the most popular captcha client on my site - reCaptcha. But I didn't found any examples or tutorials in internet... Maybe somebody knows how to do it? I'll be very appreciate for any help!!! 回答1: There is full API documentation available for reCATPCHA here. It probably has sample code, too. I found this by going to the reCAPTCHA website and clicking on the FAQ link. And of course, you sign up for the service here. That's pretty obvious from the home page. 回答2: You need to do two

pyramid_jinja2: ImportError: cannot import name Environment

[亡魂溺海] 提交于 2019-12-12 01:58:23
问题 I'm going through the tutorial for the Pyramid framework and I'm currently stuck at the one that teaches the use of Jinja2 as the templating engine.. It seems that when I run the test using nosetests , I get this odd ImportError stating that the name Environment couldn't be imported from the Jinja2 module. Funny thing is, when I pserve the site, it works just fine. It seems like this error will only occur during the test...I am currently working off a virtualenv using Ubuntu 14.04. Any

How can I pass parameters from one view to another

﹥>﹥吖頭↗ 提交于 2019-12-11 20:41:04
问题 I can't get this to work: I navigate to the page I want, but I'm doing something wrong with the variables it seems. views.py : @view_config(http_cache=1,route_name='hoofdpagina', renderer='templates/hoofdpagina.pt') def hoofdpagina(request): page = DBSession.query(MyModel) #.filter_by(id='1').all() if 'form.submitted' in request.params: name= request.params['name'] page2=Page(name) DBSession.add(page2) return HTTPFound(location=request.route_url('view_page',pagename=name)) return dict(page

Issue with pyramid framework wit Python 3.3 version

二次信任 提交于 2019-12-11 19:52:56
问题 Could you please help me to solve below error while starting my pyramid project ? c:\Python33\Scripts\v_env_testmvc_cmd\Scripts>activate (v_env_testmvc_cmd) c:\Python33\Scripts\v_env_testmvc_cmd\Scripts>cd.. (v_env_testmvc_cmd) c:\Python33\Scripts\v_env_testmvc_cmd>cd .. (v_env_testmvc_cmd) c:\Python33\Scripts>pserve.exe MyProject\development.ini --reload Traceback (most recent call last): File "c:\Python33\Scripts\pserve-script.py", line 9, in <module> load_entry_point('pyramid==1.5a3',

Can't debug a Pyramid project in Eclipse/Pydev with Waitress

梦想的初衷 提交于 2019-12-11 19:16:05
问题 I'm trying to setup a working IDE and starting to learn Python with Pyramid framework in a friendly environment like Eclipse/Pydev. All is working ok (debug, breakpoints included) if I use the old pastescript server by replacing: use = egg:waitress#main --> use = egg:Paste#http in development.ini. The problem is that the new "way to go" is to use waitress which is supported in Python 3+ versions and pastescript only works on 2.x. I would want to know if there is any kind of known issue

Pyramid: How to create-use custom dispatcher?

本秂侑毒 提交于 2019-12-11 16:24:16
问题 Besides the root url request, which will be sent to a view, I want to have a dispatcher that I will route all the requests to different views which I will chose depending on my custom dispatcher's rules. How can I create a dispatcher? I have read the docs over and over again yet I can not figure it out. I want to parse the *remainder of url and then dispatch the request accordingly. 回答1: Pyramid will dispatch the request to a view registered via add_view or view_config . If you want to

Pyramid: Multi-threaded Database Operation

放肆的年华 提交于 2019-12-11 11:28:32
问题 My application receives one or more URLs (typically 3-4 URLs) from the user, scrapes certain data from those URLs and writes those data to the database. However, because scraping those data take a little while, I was thinking of running each of those scraping in a separate thread so that the scraping + writing to the database can keep on going in the background so that the user does not have to keep on waiting. To implement that, I have (relevant parts only): @view_config(route_name="add