[web2py] encoding and decoding spaces in request.args
Hey, I am generating URLs on the go and then decoding when they are called by user. e.g. application/controller/funtion/foo/bar/. I encode foo and bar individually so that if they have spaces, they get encoded to %20 not _ which seems liked default. but when I decode it (After user calls it), web2py automatically decodes spaces into _ ,so I no longer know whether I had _ or spaces in the actual url. I want to override this default behavior of decoding to web2py. I have no idea how, any help will be appreciated. Thank you guys
[web2py] downloading a static file without streaming
Hello, I have searched a lot and also tried to forge this up but I could not locate or create functionality to download a file from the server; not stream, just normal download. response.download requires a database field and response.stream streams a file, it doesn't simple download it. (I might be confusing the difference between streaming and downloading). I tried to set chunk size in stream function more than size of file in an attempt to make it equal to download but it is not working. I am comparing it to a file hosted by SimpleHTTPServer of CPython. Any idea how can I do it? Is it about headers? Hasanat Kazmi +923464362473
[web2py:24446] web2py on Android Scripting Environment (ASE)
Google has officially released Android Scripting Environment (ASE) for Android phones. ASE supports Python. Has anyone tried to run web2py on ASE? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:24850] Re: Authentication for services
Here is an interesting behavior. i have following function @auth.requires_login() @service.json @service.jsonrpc def acceptme(): return "accepted" in this case, whatever username and password I give, I get returned "accepted" but if I put @auth.requires_login() after @service.jsonrpc, it always returns me "Object does not exist" . I call it like this: http://hasanatkazmi%40gmail.com:**...@localhost:8000/sahana/admin/call/json/acceptme Anyone has an idea whats going on? On Jun 4, 7:28 am, Alexei Vinidiktov wrote: > I've tried this with the pyjamas tutorial and it didn't work. I've > enabled user registration and registered a user whose credentials are > used in the URL below. I got a server error when a function requiring > user authentication was called. > > I changed the line > > JSONProxy.__init__(self, "../../default/call/jsonrpc", ["getTasks", > "addTask","deleteTask"]) > > to read > > JSONProxy.__init__(self, > "http://myemail%40gmail.com%3amypassw...@127.0.0.1:8000/pyjamas/defaul...";, > ["getTasks", "addTask","deleteTask"]) > > What am I missing? > > Thanks. > > > > On Mon, Jun 1, 2009 at 12:51 PM, mdipierro wrote: > > > OK. As you request since the latest version in trunk you can do > > > @auth.requires_login() > > def index(): return 'hello world' > > > and access it with > > > curl -u username:passwordhttp://127.0.0.1:8000/app/default/index > > > or > > > curlhttp://username:passw...@127.0.0.1:8000/app/default/index > > > In the latter case username and password have to be encoded by > > urllib.quote() > > > works for services too. > > > Massimo > > > On May 31, 10:43 pm, Dan wrote: > >> Since my last message on this thread, I came up with a patch to the > >>Auth.login() code that lets me do what I need, so figured I should > >> post it here. Let me know if you see any issues with this approach (or > >> improvements to it). > > >> To recap, what I want to do is to let a script runing wget (not a > >> browser)loginand then work with some parts of the app that require > >> membership in groups. I want to pass the user's name and password to > >> theloginformusing post variables in the URL. This is not normally > >> possible with web2py'sAuth.login() function, so it needs to be > >> modified, like this- > > >> referring to source code > >> here:http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc... > >> Change these 3 lines ... > >> 622 ifFORM.accepts(form, request.vars, session, > >> 623 formname='login', > >> 624 onvalidation=onvalidation): > > >> ... to be these 3 lines: > >> if username in request.vars.keys() and request.vars.password and \ > >> FORM.accepts(form, request.vars, > >> formname=None, onvalidation=onvalidation): > > >> This change lets theformtake the username and password from the > >> URL's post variables (or theformitself - but not both of course). > >> Then my script willloginusing wget's optional arguments "--keep- > >> session-cookies --save-cookies=" when submitting the user name and > >> password to the app'sloginfunction. These wget options store the > >> session cookie in a local file. Then subsequent wget calls to the > >> restricted parts of the app can use those cookies as a token to gain > >> access with the option "--load-cookies=". > > >> Apologies for straying a bit from the original use case of this > >> thread, but perhaps it's general approach will be a helpful hint. > > >> Also: I don't fully understand what the purpose of the "formname" > >> parameter is, or why it was necessary to None-ify it. If someone can > >> explain this to me, I'd appreciate it. > > >> Dan > > >> On May 29, 6:15 pm, Dan wrote: > > >> > Reviving this thread from before... I would like to have a shell > >> > script use wget to authenticate itself and access the data in a web2py > >> > application, but I haven't been able to get the web2py app to accept > >> > the post'ed email and password information, which I sent to the user/ > >> >loginURL. Is this the right way to do it? > > >> > I see some passing references to alternate authorization methods in > >> > the documentation and the code, but I haven't been able to get much > >> > detail on what those might be. For example- > > >> >http://mdp.cti.depaul.edu/examples/default/tools#authentication: > >> > "TheAuthcalls can be extended, personalized, and replaced by other > >> > authentication mechanisms which expose a similar interface." > > >> > and > >> > inhttp://mdp.cti.depaul.edu/examples/static/epydoc/web2py.gluon.tools-p... > >> > : > >> > 644 if not user: > >> > 645 ## try alternateloginmethods > >> > 646 for login_method in > >> > self.settings.login_methods: > >> > 647 if login_method != self and \ > >> > 648 login_method(request.vars > >> > [username], > >> > 649 > >> > request.vars.password): > >> > 650
[web2py:25246] Authenticating a user without creating a form
Hi, I want to programatically authenticate a user. I have username and password of a user and I want to authenticate it without created a form. Something like this: token = Auth().check(username, password) if token: .. Is it possible? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:26936] Re: killer app idea
On Jul 19, 6:21 pm, Fran wrote: > On Jul 19, 11:31 am, Yarko Tymciurak wrote: > > > ...more to the point - to forward commits / changes in the LACK of a > > network... > > Think about cell phones only passing a baton, where that cloud provides > > persistence... > > This is consistent w/ some WHO efforts also for forwarding blood tests thru > > SMS and results back "in the bush" > > In general, this is insteresting beyond the application Massimo set out. > > Ah, now *this* is stuff that I'm very interested in. > In fact I'm currently mentoring 2 GSoC projects in this area which are > based on Web2Py: > * P2P sync using > ZeroConf:http://socghop.appspot.com/student_project/show/google/gsoc2009/sahan... > * SMS > Transport:http://socghop.appspot.com/student_project/show/google/gsoc2009/sahan... > > F Don't you think using Tor solves these problems? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:27965] cron job website communication, find to find port?
I have a website where my cron job (present in application/cron) calls webservices hosted by localhost. I have the whole URL but except the port at which the website is hosted. I don't want to hardcode port 80, any idea how to do it? Hasanat Kazmi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:28489] Re: Cron @reboot can't call script?
This isn't a big problem. I placed my script in cron folder (same as crontab) and added this line @reboot script.py It worked On Aug 12, 6:31 pm, Fran wrote: > Should cron's @reboot be able to call a script or can it just call a > controller function? > > The docs just show a controller function for this > mode:http://www.web2py.com/examples/default/cron > > I'd like to be able to call an external script instead...this isn't > working even for very simple scripts though. > (The scripts run fine when called manually) > > I tried both syntaxes shown in the docs: > @reboot root *applications/sahana/cron/test.py > @reboot * * * * root *applications/sahana/cron/test.py > > Any ideas what could be wrong? > > I've tried on both XP (with Service & with Source) & Linux with Apache/ > WSGI > - how should @reboot work in the latter environment? > > XP with source, I just get this error: > WARNING:root:WEB2PY CRON Call returned code 1: > Which isn't erribly helpful... > > F --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:28545] Re: Cron @reboot can't call script?
sorry, It didn't work for me either. I thought in first place that it is working but it wasnt.. problem is still open. On Aug 13, 12:32 pm, Hasanat Kazmi wrote: > This isn't a big problem. I placed my script in cron folder (same as > crontab) and added this line > @reboot script.py > It worked > > On Aug 12, 6:31 pm, Fran wrote: > > > Should cron's @reboot be able to call a script or can it just call a > > controller function? > > > The docs just show a controller function for this > > mode:http://www.web2py.com/examples/default/cron > > > I'd like to be able to call an external script instead...this isn't > > working even for very simple scripts though. > > (The scripts run fine when called manually) > > > I tried both syntaxes shown in the docs: > > @reboot root *applications/sahana/cron/test.py > > @reboot * * * * root *applications/sahana/cron/test.py > > > Any ideas what could be wrong? > > > I've tried on both XP (with Service & with Source) & Linux with Apache/ > > WSGI > > - how should @reboot work in the latter environment? > > > XP with source, I just get this error: > > WARNING:root:WEB2PY CRON Call returned code 1: > > Which isn't erribly helpful... > > > F --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:22511] Auth problem
Hi, I am newbie to web2py. I am working on a project where multiple people will have to get different type of authentication, (e.g. teacher and student have different level of access to the system). Now the problem is that I can not create different instances of Auth class, e.g. autht = Auth(globals(), db) autht.settings.table_user = db.define_table('teacher', db.Field('first_name'), db.Field('middlename'), db.Field('last_name'), db.Field('specialization'), db.Field('highestdegre'), db.Field('housenum'), db.Field('streetnum'), db.Field('area'), db.Field('city'), db.Field('country'), db.Field('phone'), db.Field('email', requires = [IS_EMAIL(), IS_NOT_IN_DB(db,'teacher.email')]), db.Field('username'), db.Field('password', 'password', readable=False, requires=CRYPT ()), db.Field('registration_key', length = 128, writable = False, readable = False, default = ''), db.Field('createdon', 'date' , default = now), #db.Field('controller', db.controller) ) autht.define_tables() work seamlessly well but when I create another one, no matter which one is defined first it throws error, e.g I created following: authc = Auth(globals(), db) authc.settings.table_user = db.define_table('controller', db.Field('first_name'), db.Field('middlename'), db.Field('last_name'), db.Field('phone'), db.Field('email', requires = [IS_EMAIL(), IS_NOT_IN_DB(db,'teacher.email')]), db.Field('username'), db.Field('password', 'password', readable=False, requires=CRYPT ()), db.Field('registration_key', length = 128, writable = False, readable = False, default = ''), db.Field('createdon', 'date' , default = now) ) authc.define_tables() this gives me following error: ProgrammingError: (1146, "Table 'web2py.controller' doesn't exist") does this error mean that web2py didnt find controller table in db, isnt it supposed to make it itself? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:22515] Re: Auth problem
Now, I have changed database, I have switched to mysql, and whole database is empty. Now it gives me this error: Table 'web2py.teacher' doesn't exist If create table myself, it says it already exists. Any help? On May 23, 11:49 pm, Hasanat Kazmi wrote: > Hi, > I am newbie to web2py. I am working on a project where multiple people > will have to get different type of authentication, (e.g. teacher and > student have different level of access to the system). Now the problem > is that I can not create different instances of Auth class, e.g. > > autht = Auth(globals(), db) > autht.settings.table_user = db.define_table('teacher', > db.Field('first_name'), > db.Field('middlename'), > db.Field('last_name'), > db.Field('specialization'), > db.Field('highestdegre'), > db.Field('housenum'), > db.Field('streetnum'), > db.Field('area'), > db.Field('city'), > db.Field('country'), > db.Field('phone'), > db.Field('email', > requires = [IS_EMAIL(), > IS_NOT_IN_DB(db,'teacher.email')]), > db.Field('username'), > db.Field('password', 'password', readable=False, requires=CRYPT > ()), > db.Field('registration_key', length = 128, writable = False, > readable = False, default = ''), > db.Field('createdon', 'date' , default = now), > #db.Field('controller', db.controller) > ) > autht.define_tables() > > work seamlessly well but when I create another one, no matter which > one is defined first it throws error, e.g I created following: > > authc = Auth(globals(), db) > authc.settings.table_user = db.define_table('controller', > db.Field('first_name'), > db.Field('middlename'), > db.Field('last_name'), > db.Field('phone'), > db.Field('email', > requires = [IS_EMAIL(), > IS_NOT_IN_DB(db,'teacher.email')]), > db.Field('username'), > db.Field('password', 'password', readable=False, requires=CRYPT > ()), > db.Field('registration_key', length = 128, writable = False, > readable = False, default = ''), > db.Field('createdon', 'date' , default = now) > ) > authc.define_tables() > > this gives me following error: > > ProgrammingError: (1146, "Table 'web2py.controller' doesn't exist") > > does this error mean that web2py didnt find controller table in db, > isnt it supposed to make it itself? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:22525] Re: Auth problem
I have two different objects for Auth autha = Auth() authb = Auth() Can we have multiple instances of Auth, if no then why not? On May 24, 4:03 am, mdipierro wrote: > Can you post the entire code that gives the problem? > > Do you have both authc and autht? There should be only one auth. > > When delete a database make sure also delete everything in app/ > databases/ > > Massimo > > On May 23, 5:15 pm, Hasanat Kazmi wrote: > > > Now, I have changed database, I have switched to mysql, and whole > > database is empty. Now it gives me this error: > > Table 'web2py.teacher' doesn't exist > > If create table myself, it says it already exists. Any help? > > > On May 23, 11:49 pm, Hasanat Kazmi wrote: > > > > Hi, > > > I am newbie to web2py. I am working on a project where multiple people > > > will have to get different type of authentication, (e.g. teacher and > > > student have different level of access to the system). Now the problem > > > is that I can not create different instances of Auth class, e.g. > > > > autht = Auth(globals(), db) > > > autht.settings.table_user = db.define_table('teacher', > > > db.Field('first_name'), > > > db.Field('middlename'), > > > db.Field('last_name'), > > > db.Field('specialization'), > > > db.Field('highestdegre'), > > > db.Field('housenum'), > > > db.Field('streetnum'), > > > db.Field('area'), > > > db.Field('city'), > > > db.Field('country'), > > > db.Field('phone'), > > > db.Field('email', > > > requires = [IS_EMAIL(), > > > IS_NOT_IN_DB(db,'teacher.email')]), > > > db.Field('username'), > > > db.Field('password', 'password', readable=False, requires=CRYPT > > > ()), > > > db.Field('registration_key', length = 128, writable = False, > > > readable = False, default = ''), > > > db.Field('createdon', 'date' , default = now), > > > #db.Field('controller', db.controller) > > > ) > > > autht.define_tables() > > > > work seamlessly well but when I create another one, no matter which > > > one is defined first it throws error, e.g I created following: > > > > authc = Auth(globals(), db) > > > authc.settings.table_user = db.define_table('controller', > > > db.Field('first_name'), > > > db.Field('middlename'), > > > db.Field('last_name'), > > > db.Field('phone'), > > > db.Field('email', > > > requires = [IS_EMAIL(), > > > IS_NOT_IN_DB(db,'teacher.email')]), > > > db.Field('username'), > > > db.Field('password', 'password', readable=False, requires=CRYPT > > > ()), > > > db.Field('registration_key', length = 128, writable = False, > > > readable = False, default = ''), > > > db.Field('createdon', 'date' , default = now) > > > ) > > > authc.define_tables() > > > > this gives me following error: > > > > ProgrammingError: (1146, "Table 'web2py.controller' doesn't exist") > > > > does this error mean that web2py didnt find controller table in db, > > > isnt it supposed to make it itself? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:37959] Re: Retrieve Images From Database
I have a quick question, how do I show an image stored in database (as blob; the default used in web2py when image is stored using crud) like, if some one embeds link like /image/24 , it shows image not html (i mean, content type is automatically set)? On Nov 19, 10:02 pm, mdipierro wrote: > for now you can do: > > import base64 > rows=db(db.tablename.id>0).select() > for row in rows: > row.blobfield=base64.b64encode(row.blobfield) > rows.export_to_csv_file(file) > > On Nov 19, 10:52 am, mdipierro wrote: > > > This needs to be fixed. It is tricky to do but I will put on the todo > > list. > > > On Nov 19, 10:14 am, ecall wrote: > > > > I'm trying to export/import database having an "upload" field stored > > > as ablobrefered by a "uploadfield". > > > Infortunatly, theblobis saved as binary data, this makes the CSV > > > file useless... I was expecting that was base64 data. > > > > Is there a way to tell "export_to_csv_file()" to use base64 for the > > >blob? > > > > Thx > > > Edouard > > > > On Nov 18, 1:41 pm, mdipierro wrote: > > > > > what do you mean by "calling"? The garbage is theimage. > > > > > On Nov 17, 11:39 pm, David wrote: > > > > > > I was storing the images in postgres. When I tried calling theimage > > > > > by the filename it returned the coded filename. When I tried calling > > > > > theimageblobit returned garbage. > > > > > > I was just wondering if there was an example on how to call the images > > > > > from the database as it isn't mentioned in the manual and I don't know > > > > > what takes place on GAE. > > > > > > On Nov 17, 7:35 pm, mdipierro wrote: > > > > > > > This is all automatic in web2py is you do not rename the uploaded > > > > > > files. > > > > > > > On Nov 17, 7:18 pm, Beerc wrote: > > > > > > > > Storing images in database is a bad idea GENERALLY. > > > > > > > But on GAE you can't write the file system, so you have no other > > > > > > > choice for persistent storage. > > > > > > > > And you will see garbage instead ofimageif MIME type incorrect or > > > > > > > unsetted. > > > > > > > In general case the web server (e.g. Apache) will set it for you > > > > > > > automatically (if its configuration is correct). > > > > > > > But if YOU serve the files (as in case of GAE) instead of the web > > > > > > > server, then you must to set the MIME type in the HTTP header. > > > > > > > Example > > > > > > > for a JPEG file: > > > > > > > Content-Type:image/jpg > > > > > > > Seehttp://en.wikipedia.org/wiki/MIMEfordetails. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.