web2py

Function call using import in web2py

醉酒当歌 提交于 2019-12-11 04:36:36
问题 I have split the code into multiple files. I have imported all the functions from all other files into admin.py. Lets say I want to call a function XYZ. If I give path to function as admin/XYZ it gives me error as invalid function and for this I have to give the path as file_with_XYZ_function/XYZ . Is there a way to overcome this problem and simple call all the imported functions from one single file 回答1: NOTE: This might not be answering your question as I'm not sure I understand your

web2py components

☆樱花仙子☆ 提交于 2019-12-11 03:26:09
问题 I would like to load different web2py components in the same view, but not at the same time. I have 5 .load files which have form fields for a different scenario, these are called dynamically by an onchange select script. Is it possible with web2py to do this? 回答1: Yes, but in that case, don't use the LOAD() helper in the web2py view, as that will generate Javascript that loads the component immediately upon page load. Instead, create a div with an id to hold the component, and have your

How to run a task outside web2py and retrieve the output [duplicate]

▼魔方 西西 提交于 2019-12-11 02:13:31
问题 This question already has answers here : Asynchronous background processes with web2py (3 answers) Closed 6 years ago . Getting extended processing times inside web2py when running clustering algorithms. Tried running the algorithm on a standalone python instance and it finishes in 4-5s, in web2py, it takes over 10 minutes. How do I pass the parameters from web2py user input to run the algorithm on a separate python instance, finish in 4-5s and return the results to web2py user view? 回答1: You

Should I be installing my Python modules?

蓝咒 提交于 2019-12-11 02:10:00
问题 I generally don't bother to install Python modules. I use web2py, and just dump them in the modules folder and let it take care of the local imports. It just always seemed like the most straightforward way of doing things- never felt right about handling dependencies at a system-wide level, and never felt like messing with virtual envs. On one of my other questions, the answerer said Generally, the best practice for 3rd party modules is to install them via pip or easy_install (preferably in a

How can I create new auth_user and auth_group on Web2py running on Google App Engine (GAE)?

假如想象 提交于 2019-12-11 00:49:57
问题 I've created an app on my local computer with Web2py and it is running via WSGI with SQLite. I can successfully deploy my app to Google App Engine, using my own domain and doing all url rewrites I need. Now I need a way to create specific administrative users that will be responsible for update some tables. Specific questions: Is there a way I can use Web2py admin interface when my appliation is running on GAE ? Even if I do not want create news applications nor edit files, is it possible to

Need help understanding module import errors

北城以北 提交于 2019-12-10 20:33:59
问题 I'm trying to use the sendgrid Python API as a module in web2py. After testing it successfully from the command line, I dropped it into my modules folder, but as soon as I try to import sendgrid into my controller file, I get: File "applications/test/modules/sendgrid/__init__.py", line 4, in <module> del sendgrid, message NameError: name 'sendgrid' is not defined Looking at the __init__.py file, I noticed they're doing * imports on the module level, which I've seen cause problems before, but

Why does web2py crash for me upon startup?

感情迁移 提交于 2019-12-10 18:08:36
问题 I"m trying to get web2py running on an Ubuntu machine. All the docs seem to indicate that to run it on a *nix system, you download the source and do: python web2py.py I grabbed the source (stable source, not the trunk, version 1.99.4) and tried the above, but after entering a password for the server I get (in the terminal): $ python web2py.py web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.99.4 (2011-12-14 14:46:14) stable Database drivers available: google

Web2py form field options

空扰寡人 提交于 2019-12-10 18:04:34
问题 I am using web2py forms and i want to have some fields only visible to user (as fixed which cannot be edited). I tried making various combinations of editable, writeable, readonly but was of no use. I looked into web2py book too but that also seems insufficient. It would be great if someone can tell me how to do this. 回答1: You mean some fields visible to all visitors and some fields visible only if logged in? If that's the case, then build your form conditionally: form_fields = [ Field(

Cleaning up web2py my controllers

末鹿安然 提交于 2019-12-10 04:09:57
问题 My controllers are getting a bit cluttered in my web2py app, and I would like to move functions to another place. I was initially thinking of moving them to modules, but I access the db sometimes, and have other parameters set in db.py (me for user id, now for the date, etc.). Is there a clean way to move these functions to a new file while still having access to the variables I need? I'm not opposed to something like from db import me, now 回答1: You controller actions (i.e., the actions that

Web2Py - Upload a file and read the content as Zip file

可紊 提交于 2019-12-10 00:45:42
问题 I am trying to upload a zip file from Web2Py form and then read the contents: form = FORM(TABLE( TR(TD('Upload File:', INPUT(_type='file', _name='myfile', id='myfile', requires=IS_NOT_EMPTY()))), TR(TD(INPUT(_type='submit',_value='Submit'))) )) if form.accepts(request.vars): data=StringIO.StringIO(request.vars.myfile) import zipfile zfile=zipfile.Zipfile(data) For some reason this code does work and complains of file not being a zip file although the uploaded file is a zip file. I am new to