web2py

CORS Issue with API running on Web2Py

若如初见. 提交于 2019-12-11 09:42:40
问题 I've searching a lot and although I found similar issues, it seems that I haven't found my answer yet and maybe you can help me. I have the following API on my Web2Py framework and I am accessing it with a AngularJS front-end app and I am having CORS issues (I already tried * in the orign or my specific IP and port but no good results). Nevertheless, it does work with IE but not with Chrome or Mozilla. @request.restful() def api(): def GET(): key = main() #generate random XML and returns the

web2py send uploaded file like email attachment

痴心易碎 提交于 2019-12-11 08:42:12
问题 I i've done an app in web2py to store FAQ and that give me the possibility to send those FAQ via EMAIL, i'd like to send (when i got that) also an attachment that i upload in the FAQ that i create. I'v got this in my DB: db.define_table('faq', Field('tipo',db.tipo_faq), Field('sotto_categoria',db.sotto_categoria_faq), Field('oggetto', requires = (IS_UPPER(), IS_NOT_EMPTY())), Field('testo_faq',type='text',requires = (IS_UPPER(), IS_NOT_EMPTY())), Field('note',type='text',requires = IS_UPPER()

Google App Engine add image to page with static folder

佐手、 提交于 2019-12-11 08:36:40
问题 i have a problem to use image with static folder path in my page. this is my app.yaml application: something version: 1 runtime: python27 api_version: 1 threadsafe: yes handlers: - url: /images static_dir: static/images - url: /favicon.ico static_files: static/favicon.ico upload: static/favicon.ico - url: .* script: main.app libraries: - name: webapp2 version: "2.5.2" - name: jinja2 version: latest I have templates, static/images, controllers (has MainHandler.py) folders and in my root i have

Different ajax calls with polling cycle

China☆狼群 提交于 2019-12-11 08:19:48
问题 Let's assume the first ajax call is immediately made, the controller-called function loops until something is read, for example: def FirstAjax(): while True: if something is read: val = something break return val Before something is read the user presses the "Back" button and a new ajax request is sent, for example: def SecondAjax(): print "Response from second ajax" The second ajax call is really called (obviously, we're talking about async stuff :) ) but the text is not printed until the

in web2py, can I get newlines in the output of HTML helpers?

非 Y 不嫁゛ 提交于 2019-12-11 08:04:57
问题 I am making a table with web2py HTML helpers. My code is based on the example from the web2py book: >>> table = [['a', 'b'], ['c', 'd']] >>> print TABLE(TR(*table[0]), TR(*table[1])) <table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table> I have quite a large table, but this approach places all output on one big line. For readability of the HTML, I would appreciate a way to add newlines after each </tr>. I like the HTML helper functions so prefer not to go for the plain {

How to best design a date/geographic proximity query on GAE?

孤者浪人 提交于 2019-12-11 06:38:40
问题 I'm building a directory for finding athletic tournaments on GAE with web2py and a Flex front end. The user selects a location, a radius, and a maximum date from a set of choices. I have a basic version of this query implemented, but it's inefficient and slow. One way I know I can improve it is by condensing the many individual queries I'm using to assemble the objects into bulk queries. I just learned that was possible. But I'm also thinking about a more extensive redesign that utilizes

Adding a column of checkboxes to an SQLFORM.grid

别等时光非礼了梦想. 提交于 2019-12-11 06:27:27
问题 I'd like to have a grid in which the first column contains no header, and consists of checkboxes, the last couple of columns are columns of links (generated with the 'links' parameter), and the intermediate columns are generated from database fields with the 'fields' parameter. What's the best way to go about generating the column of checkboxes? Thank you. 回答1: grid = SQLFORM.grid(..., selectable=lambda ids: [do something with record ids]) That will add a column of checkboxes on the left and

return a list as JSON from web2py

强颜欢笑 提交于 2019-12-11 05:47:18
问题 Is there any way to return a list as a JSON list from web2py? when I hit my route ending in .json , web2py converts dictionaries into valid JSON. If the return value is a list however, it behaves unexpectedly return ["test", "test"] displays testtest and return [dict(test="test"), dict(test="test")] breaks it completely (chrome complains with ERR_INVALID_CHUNKED_ENCODING). The expect behaviour is obviously the following valid JSON strings respectively: ["test", "test"] and [{"test":"test"}, {

web2py - Controller function isn't called when using anchor tag callback

狂风中的少年 提交于 2019-12-11 05:33:48
问题 When a user visits a magazine page, a button should appear that will allow the currently logged in user to subscribe to a particular magazine if that user is already logged in. The button should not be visible to an anonymous user. I have gotten the button to show up when the user has logged in, but clicking on the button doesn't call my controller function. If this is the controller function: @auth.requires_login() def subscribe(): mag_id = request.args(0, cast=int) db.subscribe.insert

Python 2.5.6 build error on Mac Lion

南笙酒味 提交于 2019-12-11 05:31:29
问题 Here is what I would like to do. Use web2py with MySQL. To do that, I need to use source web2py rather than web2py.app To use web2py, I need Python 2.5 I am having trouble building and installing Python 2.5 I downloaded Python-2.5.6.tgz from Python release page. Now, I did ./configure and then make Then, I get the following error. gcc -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD