web.py

session in webpy - getting username in all classes

百般思念 提交于 2019-12-05 07:16:42
问题 I am using webpy framework for my project. I am logging in from my 'login' class of main.py program. I want to get the username in some other class. I tried with session and experimented with it for a long time. I have implemented session like below. store = web.session.DiskStore('sessions') session = web.session.Session(app,store,initializer={'login': 0,'privilege': 0}) in my login class of main.py the following code will work when user submit username and password.(This is the post method

how can I use uwsgi web.py to run background function?

自古美人都是妖i 提交于 2019-12-05 05:34:36
问题 Say I need to send an email to myself when there is new comment. and I don't want to block web.py presenting HTML to browser. and Threading seems don't work here. class comment: def POST(self): ... sender = Thread(target=_sendmail,args=('New Comment',msg)) sender.start() referer = web.ctx.get('HTTP_REFERER', 'http://www.domain.com') raise web.SeeOther(referer) the problem when using threading is that once POST function is finished.. the sender within it would be freezed..usually sender didn't

web.py deployment for iOS app backend

孤街醉人 提交于 2019-12-05 04:56:59
问题 I am currently developing an iOS application that needs a backend to pull data from. I have implemented the backend using Python, web.py and pymongo. I deployed everything on an EC2 instance, assigned an elastic IP to the instance that the iOS devices call to access the backend, and launch the application through SSH by doing: nohup python main.py & Everything works fine (couple dozen users a day, with potential to grow; data transferred is rarely more than a few kilobytes), but I'm wondering

I get 'ImportError: No module named web' despite the fact that it is installed

随声附和 提交于 2019-12-04 20:38:17
I would like to run a simple 'Hello world' app. Every time I run it I get 'ImportError: No module named web' I installed web.py using pip and using easy_install several times. I tried uninstalling it and installing again. I tried installing it a as sudo. Nothing seems to work. I use OS X Code of the application: import web urls = ( '/', 'index' ) app = web.application(urls, globals()) class index: def GET(self): greeting = "Hello World" return greeting if __name__ == "__main__": app.run() I tried to run this app using this commend: python /Users/mptorz/webversion/bin/app.py http://0.0.0.0:8080

python apscheduler not consistent

為{幸葍}努か 提交于 2019-12-04 16:35:28
I'm running a scheduler using python apscheduler inside web.py framework. The function runserver is supposed to run everyday at 9 a.m but it is inconsistent. It runs most days but skips a day once in a while. Code: import web from apscheduler.schedulers.blocking import BlockingScheduler #Blocking Scheduler #URLs urls = ( '/startscheduler/','index', ) Nightlysched = BlockingScheduler() @Nightlysched.scheduled_job('cron', hour=9) def runserver(): print 2+2 #doing some calculations here #Main function to run the cron JOB if __name__ == "__main__": Nightlysched.start() #stating the job app = web

No module named utils error on compiling py file

╄→尐↘猪︶ㄣ 提交于 2019-12-04 12:24:56
问题 I'm trying to run a .py file through the command prompt using the command "python filename.py". I've already set the environment variables for python after I installed it, so I don't get any error when I type python. The file I'm running imports a few directories, all of which are preexistent in the same directory as the file I'm running, apart from the file web.py, which I can't seem to locate in the directory, so I'm assuming it's somewhere inside the python package, I have downloaded. But,

web.py: how to get POST parameter and GET parameter?

≡放荡痞女 提交于 2019-12-04 03:05:58
I'm new to web.py . I used PHP alot. In PHP, POST parameter and GET parameter is stored in different global variables For example: curl http://127.0.0.1/test?get_param1=1 -d 'post_param1=2' In PHP you can get $_GET['get_param1'] is 1 and $_POST['post_param1'] is 2. But it seems impossible to distinct GET/POST parameters in web.py ? I can only use web.input() to get GET/POST parameters in a dict-like object, but I cannot tell which of them is from the query string and which is from POST data There's actually an (undocumented?) _method parameter that can be get , post or both (the default) to

session in webpy - getting username in all classes

梦想的初衷 提交于 2019-12-03 21:41:23
I am using webpy framework for my project. I am logging in from my 'login' class of main.py program. I want to get the username in some other class. I tried with session and experimented with it for a long time. I have implemented session like below. store = web.session.DiskStore('sessions') session = web.session.Session(app,store,initializer={'login': 0,'privilege': 0}) in my login class of main.py the following code will work when user submit username and password.(This is the post method 0f my login class). class login: def POST(self): i = web.input(form_submit="Login") authdb = sqlite3

web.py deployment for iOS app backend

一曲冷凌霜 提交于 2019-12-03 20:47:55
I am currently developing an iOS application that needs a backend to pull data from. I have implemented the backend using Python, web.py and pymongo. I deployed everything on an EC2 instance, assigned an elastic IP to the instance that the iOS devices call to access the backend, and launch the application through SSH by doing: nohup python main.py & Everything works fine (couple dozen users a day, with potential to grow; data transferred is rarely more than a few kilobytes), but I'm wondering if this is the proper way to do things. For instance on the web.py website, they explain ways to use

Google app engine users Auth: Djangoappengine Vs Web2py Vs Webpy

寵の児 提交于 2019-12-03 17:50:17
问题 I'm going to develop a small web application on Gae with a registration section, login\logout and stuff like that. Since Google app Engine does not support session out of the box and I don't want to restrict access using google Accounts, I am forced to pick a Framework that offers this kind of facilities. My choices are: Web2py Djangoappengine Webpy Reading its book, Web2py seems to offer session object and has a good access control, offering an Auth class that implements Role-Based Access