pyramid

pre-select html select option after window.location redirect

有些话、适合烂在心里 提交于 2019-12-11 11:02:20
问题 I have problem where after the page is redirected, I want the select to have the previously selected option as the selected choice after the page has been redirected. here I have an onchange for my select which will redirect the user depending on their selection(refresh page basically), however after the page refresh the selected option gets reset and the first option in the list get selected. $("#reportTypes").change(function () { var reportTypeID = $(this).val(); var deviceTypeID = $('

Get Pyramid View callable by it's path (request context)

前提是你 提交于 2019-12-11 11:01:38
问题 I am making an app that would translate websocket messages to AJAX requests to the server. Mainly the decision is based on the fact that Pyramid already has a good URL dispatch system and it would be stupid not to use it. The question is if there is an easy way to dispatch a URL in Pyramid (possibly an instanced Request object) to it's according view callable and get the view callable? Or at least get the output of the view callable related to the request? I have tried the script from

python Requests login to website returns 403

主宰稳场 提交于 2019-12-11 08:39:35
问题 I'm trying to use requests to login to a website but as you can guess I'm having a problem here's the the code that I'm using import requests EMAIL = '***' PASSWORD = '***' URL = 'https://portal.bitcasa.com/login' client = requests.session(config={'verbose': sys.stderr}) login_data = {'username': EMAIL, 'password': PASSWORD,} r = client.post(URL, data=login_data, headers={"Referer": "foo"}) print r and if I print out r.text I get <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

Occasionally disabling Pyramid middleware

落花浮王杯 提交于 2019-12-11 08:32:31
问题 Note : If it's any help, I'm using Pyramid 1.3.2. I know it's a little out of date, I would prefer not to update right away, but I might be able to force an update if the latest version provides better support for this use case. The Pyramid-based application I'm working on has a strict authorization policy: all calls must be authenticated. Since 1) it's tedious to add this manually on every request handelr; and 2) we don't want anybody to "forget" adding authentication, we enforce this server

Hello world of sprox with pyramid - part 2

好久不见. 提交于 2019-12-11 06:51:25
问题 I've tried to build the simplest possible form in Sprox using pyramid. # model.py class Allocation: # some fields ... class SproxForm(AddRecordForm): __model__ = Allocation sprox_form = SproxForm(DBSession) # views.py @view_config(route_name='sprox_add', renderer='templates/sprox.pt') def sprox_form_add(request): return {'form':sprox_form,'form_input':{}} <!-- sprox.pt --> <html> <body> <div tal:content="structure form(form_input)"/> </body> </html> When I navigate to that view in the browser

How should an index.html file be served from Python Pyramid for an AngularJS app?

99封情书 提交于 2019-12-11 06:38:49
问题 I am getting into single-page apps with AngularJS but rather than using Node or similar, I am most comfortable with Python on the server. So, given I am somewhat familiar with Pyramid, I plan to use the pyramid_rpc module to return JSON objects to the client app. That's all straight forward enough, however, what then is the best way to serve the starting index file which contains the AngularJS initial AngularJS app? Usually, static files are served from a static directory, but is there any

Pyramid on Google’s App Engine using buildout resulting in setuptools not found error

孤者浪人 提交于 2019-12-11 05:16:44
问题 I am trying to run pyramid application on google's app engine using buildout. I followed this link gae_buildout and got struck while running the buildout. Its shows "setuptools not found error" despite of seetuptools being installed in the virtual environment. I tried few work arounds and nothing turned fruitful, any thoughts on this ? Find the error trace below. I am using pyramid 1.4 version. An internal error occurred due to a bug in either zc.buildout or in a recipe being used: Traceback

404 The resource could not be found

喜夏-厌秋 提交于 2019-12-11 04:54:48
问题 Getting 404 Resource not found when trying to access a single item as anonymous i.e. no authenticated. I would expect instead a 403 Forbidden since I have setting permission on the view config. class BookShow(FormView): """Show one instance of a model.""" resource_buttons = [...] @view_config(route_name="book", context=BookResource, name="", renderer="site/workspace/book/single.html", permission="authenticated") def book(self): ... return locals() My views init has the traversal set as: self

Pyramid traversal HTTP PUT to URI that doesn't exist

六月ゝ 毕业季﹏ 提交于 2019-12-11 04:48:51
问题 So I have a pyramid traversal app and I'd like to be able to PUT to URIs that don't exist. Is there a way to do this in the view config? So for example I have this @view_defaults(context=models.Groups, renderer='json') @view_config(request_method='GET') class GroupsView(object): def __call__(self): ''' This URI corresponds to GET /groups ''' pass @view_config(request_method='PUT') def put(self): ''' This URI should correspond to PUT /groups/doesnotexist ''' pass Of course the put doesn't work

Deploy Pyramid Application on Elastic Beanstalk

孤街醉人 提交于 2019-12-11 04:41:47
问题 Does anyone have experience installing a Pyramid application via Elastic Beanstalk ? My application deploys but I cannot configure the application's application.py (or pyramid.wsgi ) file to work properly. Within get_app the following error occurs: File "/opt/python/run/venv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 829, in resolve [Sun Jul 17 21:24:15.482379 2016] [:error] [pid 736] [remote 127.0.0.1:9522] raise DistributionNotFound(req, requirers) [Sun Jul 17 21:24:15