Re: [web2py] Free e-book abhout Rest API
Thank you for this. Jon Molesa On Apr 24, 2012, at 4:44 PM, Bruno Rocha rochacbr...@gmail.com wrote: Download: http://blog.apigee.com/detail/announcement_new_ebook_on_web_api_design/ -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: mailing with pgp
gpg --list-secret-keys my_from_addr...@xyz.com produces an output that indicates that the address is valid. So I know I'm using the right email address. If I purposely enter an invalid email as a test, I get an error message: gpg: error reading key: secret key not available There is a GPGKEY environmental variable that is exported and is set to a value revealed by the above --list-secret-keys command. On Thursday, April 26, 2012 11:55:36 AM UTC+8, szimszon wrote: what is the output of the gpg --list-secret-keys my_from_addr...@xyz.com command if running with web2py user? Is there any environment variable set about gpg in a shell and not in environment the web2py is running? 2012. április 26., csütörtök 1:02:40 UTC+2 időpontban weheh a következőt írta: no key for signing my_from_addr...@xyz.com On Thursday, April 26, 2012 2:29:53 AM UTC+8, szimszon wrote: What is the error message? 2012. április 25., szerda 19:28:10 UTC+2 időpontban weheh a következőt írta: Thanks szimszon. I see. The keyrings were not installed under web2py. But now they are, and unfortunately, I'm still failing out in the same place (although now I have a better idea where). The message is that there is no key for signing my_from_addr...@xyz.com, which is the mail.settings.sender setting. I tried regenerating the keys (the originals had been done by another person), but it's still not working (same error message). I think the mail code is OK. But perhaps the keys are not. What's your suggestion? On Wednesday, April 25, 2012 10:13:36 PM UTC+8, szimszon wrote: In linux web2py user's keyring is in ~web2py/.gnupg/{pubring.gpg,secring.gpg} It's the default location. If you'll sign the mail than the private key should belong to 'x...@y.com '. Can you send mail if there is no gpg in action? Is smtp working? If I get some time at night I'll look at the code... 2012. április 25., szerda 15:39:32 UTC+2 időpontban weheh a következőt írta: # this is my controller def test_mail(): Email tester mail.settings.sender = 'x...@y.com' mail.settings.server = 'z.com:587' # SMTP server mail.settings.login = 'asdf:lkjh' mail.settings.encrypt = False mail.settings.ssl = False mail.settings.tls = True mail.settings.cipher_type = 'gpg' mail.settings.sign = True mail.settings.sign_passphrase = 'foobar' msg = ''this is a test' print mail.send( to='q...@r.com', reply_to=mail.settings.sender, subject='test', message=msg, raw=True, ) redirect(URL(...)) There is no ticket thrown by running this controller. The key appears to be the right key. mail.error == None. What exactly is a keyring and how is it specified? How is it any different than mail.settings.sign_passphrase as my private key? And isn't my mail.settings.sender my public key? On Wednesday, April 25, 2012 2:50:05 PM UTC+8, szimszon wrote: Sorry for that. I have little time :( Is there anything in mail.error after the mail.send(...)? The user running web2py has a pgp keyring with the right keys? Is there any exception during mail.send? Can you post the code you are using? 2012. április 25., szerda 1:06:14 UTC+2 időpontban weheh a következőt írta: I'm running 1.99.7 and none of the arguments to mail.send are valid. All the mail variables must be set via mail.settings as far as I can tell. That said, I have all my settings in place but things still not working. I'm going to start digging into mail logs next. On Tuesday, April 24, 2012 9:45:39 PM UTC+8, szimszon wrote: I have no little time sorry, I found the original testing code I used: #!/usr/bin/env python from gluon.tools import * mail=Mail() mail.settings.server='smtp server' mail.settings.sender='sender@address' mail.settings.login='user:pass' print mail.send('rec@address','test1','sign+encrypt',cipher_type='gpg',sign_passphrase=pass for gpg key) print mail.send('rec@address','test2','sign',cipher_type='gpg',encrypt=False,sign_passphrase=pass for gpg key) print mail.send('rec@address','test3','encrypt',cipher_type='gpg',sign=False,sign_passphrase=pass for gpg key) print mail.send('rec@address','test4','no sign+no encrypt') print mail.error You need to have a trusted gpg key for rec@address in your keyring (web2py user's keyring) and for sign you need to have a private key in the keyring of a web2py user (the user running the web2py website) 2012. április 24., kedd 15:03:07 UTC+2 időpontban weheh a következőt írta: I'm still not getting this to work. Would you mind posting a complete example? Thanks.
Re: [web2py] Free e-book abhout Rest API
Thx +1 +adesst -Original Message- From: Jon Molesa rjmol...@gmail.com Sender: web2py@googlegroups.com Date: Thu, 26 Apr 2012 02:26:31 To: web2py@googlegroups.comweb2py@googlegroups.com Reply-To: web2py@googlegroups.com Subject: Re: [web2py] Free e-book abhout Rest API Thank you for this. Jon Molesa On Apr 24, 2012, at 4:44 PM, Bruno Rocha rochacbr...@gmail.com wrote: Download: http://blog.apigee.com/detail/announcement_new_ebook_on_web_api_design/ -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: attachment;filename=%s.ics
You do not give your context so I don't know whether you have access to row, but if you have: {{response.headers['Content-Disposition'] = attachment;filename=%s_%s.ics % ( IS_SLUG()(organization.name)[0], row.id)}} It's straight python I think. Le mercredi 25 avril 2012 10:47:57 UTC+2, Annet a écrit : In a .ics view I generate the file name as follows: {{response.headers['Content-Disposition'] = 'attachment;filename=%s.ics' % IS_SLUG()(organization.name)[0]}} I'd like to add the row.id to the file name as well, I've tried several ways but none of them worked, what is the correct syntax to do this. Kind regards, Annet.
[web2py] byday=MO versus byday=row.Day.byday
I defined tables Day and OpeningHours: db.define_table('Day', Field('name',length=16, default='',notnull=True,unique=True), Field('byday',length=2,default='',notnull=True,unique=True), format='%(name)s', migrate=False) db.define_table('OpeningHours', Field('nodeID','reference Node',default='',notnull=True,ondelete='CASCADE',writable=False,readable=False), Field('dayID','reference Day',default='',notnull=True,ondelete='RESTRICT'), Field('date',type='date'), Field('fromTime',type='time'), Field('toTime',type='time'), migrate=False) When I query the database, rows (OpeningHours and Day joined) reads like: nodeIDfromTimetoTimebyday 1 09:00 12:00 MO 1 15:00 22:00 MO 1 09:00 22:00 TU 1 09:00 12:00 WE 1 12:00 15:00 WE 1 09:00 22:00 TH 1 09:00 22:00 FR 1 09:00 13:00 SA 1 10:00 13:00 SO In a function I set the date on the fields as follows: nowdate=request.now.date() nowday=request.now.weekday() for row in session.oh_rows: if nowday==row.Day.id-1: row.OpeningHours.date=nowdate else: byday=row.Day.byday row.OpeningHours.date=nowdate+relativedelta(weekday=byday) For some reason this results in an error: Traceback (most recent call last): File /Library/Python/2.5/site-packages/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/calendar.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/calendar.py, line 178, in module File /Library/Python/2.5/site-packages/web2py/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/calendar.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/calendar.py, line 57, in openingHours row.OpeningHours.startDate=nowdate+relativedelta(weekday=byday) File applications/bootstrap/modules/relativedelta.py, line 278, in __radd__ weekday, nth = self.weekday.weekday, self.weekday.n or 1 AttributeError: 'str' object has no attribute 'weekday' When I manually set byday=row.Day.byday to byday=MO the code runs without problems, changing MO to TU, WE, FR, SA and SU also runs without problem. What's wrong with row.Day.byday? When I put {{=row.Day.byday}} in the view it displays: MO TU WE etc. KInd regards, Annet.
[web2py] Re: attachment;filename=%s.ics
Hi Cédric, It's straight python I think. That's what I thought, but it results in the following error ticket. Traceback (most recent call last): File /Library/Python/2.5/site-packages/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/views/calendar/downloadVevent.ics, line 1, in module {{response.headers['Content-Disposition'] = 'attachment;filename=%s_%s.ics' % IS_SLUG()(organization.name)[0], row.id}}BEGIN:VCALENDAR TypeError: not enough arguments for format string Kind regards, Annet.
[web2py] Re: attachment;filename=%s.ics
This is what it has to be: {{response.headers['Content-Disposition'] = 'attachment;filename=event_%s_%s.ics' % ((IS_SLUG()(organization.name)[0]), row.id)}}
[web2py] Re: how to create login form
How to change the layout representation of auth login form
[web2py] Re: how to create login form
You can customize it the same way as any SQLFORM. First, you can change the formstyle via the auth.settings.formstyle setting (default is table3cols, but you can change it to table2cols, divs, or ul). If you need more customization, see http://web2py.com/books/default/chapter/29/7#Custom-forms . Anthony On Thursday, April 26, 2012 8:53:40 AM UTC-4, Vibhor Purandare wrote: How to change the layout representation of auth login form
[web2py] Re: byday=MO versus byday=row.Day.byday
Is byday just a string? If so, how could it have a weekday and an n attribute? Anthony On Thursday, April 26, 2012 3:59:20 AM UTC-4, Annet wrote: I defined tables Day and OpeningHours: db.define_table('Day', Field('name',length=16, default='',notnull=True,unique=True), Field('byday',length=2,default='',notnull=True,unique=True), format='%(name)s', migrate=False) db.define_table('OpeningHours', Field('nodeID','reference Node',default='',notnull=True,ondelete='CASCADE',writable=False,readable=False), Field('dayID','reference Day',default='',notnull=True,ondelete='RESTRICT'), Field('date',type='date'), Field('fromTime',type='time'), Field('toTime',type='time'), migrate=False) When I query the database, rows (OpeningHours and Day joined) reads like: nodeIDfromTimetoTimebyday 1 09:00 12:00 MO 1 15:00 22:00 MO 1 09:00 22:00 TU 1 09:00 12:00 WE 1 12:00 15:00 WE 1 09:00 22:00 TH 1 09:00 22:00 FR 1 09:00 13:00 SA 1 10:00 13:00 SO In a function I set the date on the fields as follows: nowdate=request.now.date() nowday=request.now.weekday() for row in session.oh_rows: if nowday==row.Day.id-1: row.OpeningHours.date=nowdate else: byday=row.Day.byday row.OpeningHours.date=nowdate+relativedelta(weekday=byday) For some reason this results in an error: Traceback (most recent call last): File /Library/Python/2.5/site-packages/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/calendar.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/calendar.py, line 178, in module File /Library/Python/2.5/site-packages/web2py/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/calendar.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/calendar.py, line 57, in openingHours row.OpeningHours.startDate=nowdate+relativedelta(weekday=byday) File applications/bootstrap/modules/relativedelta.py, line 278, in __radd__ weekday, nth = self.weekday.weekday, self.weekday.n or 1 AttributeError: 'str' object has no attribute 'weekday' When I manually set byday=row.Day.byday to byday=MO the code runs without problems, changing MO to TU, WE, FR, SA and SU also runs without problem. What's wrong with row.Day.byday? When I put {{=row.Day.byday}} in the view it displays: MO TU WE etc. KInd regards, Annet.
[web2py] Re: how to create login form
Thank's On Thursday, April 26, 2012 6:46:21 PM UTC+5:30, Anthony wrote: You can customize it the same way as any SQLFORM. First, you can change the formstyle via the auth.settings.formstyle setting (default is table3cols, but you can change it to table2cols, divs, or ul). If you need more customization, see http://web2py.com/books/default/chapter/29/7#Custom-forms. Anthony On Thursday, April 26, 2012 8:53:40 AM UTC-4, Vibhor Purandare wrote: How to change the layout representation of auth login form
[web2py] Re: attachment;filename=%s.ics
It should also work without the extra parentheses around IS_SLUG: 'attachment;filename=event_%s_%s.ics' % (IS_SLUG()(organization.name)[0], row.id) Anthony On Thursday, April 26, 2012 6:16:38 AM UTC-4, Annet wrote: This is what it has to be: {{response.headers['Content-Disposition'] = 'attachment;filename=event_%s_%s.ics' % ((IS_SLUG()(organization.name)[0]), row.id)}}
[web2py] Ubuntu and Python3
People at Canonical are thinking on releasing the next Ubuntu (12.10) with Python3 as default. Wouldn't be nice to start developing web3py to be available in 6 months?
[web2py] Re: Ubuntu and Python3
another article http://www.wefearchange.org/2012/04/python-3-on-desktop-for-quantal-quetzal.html On Thursday, April 26, 2012 2:29:47 PM UTC+1, Francisco Costa wrote: People at Canonical are thinking on releasing the next Ubuntu (12.10) with Python3 as default. Wouldn't be nice to start developing web3py to be available in 6 months?
[web2py] Re: storing objects in session
Some how this doesn't result in an error ticket, has anything changed? Yes, after your original query, we fixed it -- Rows objects are now stored and retrieved as a list of Row objects instead of a list of dictionaries. Note, when Row objects are stored in the session (either individually or as part of a Rows object), they lose their .update_record() and .delete_record() methods, as those are lambda functions stored with each Row (and cannot be pickled). They also lose the Set objects that enable recursive selects ( http://web2py.com/books/default/chapter/29/6#Recursive-selects) with linked tables. So, the pickled/unpickled Row objects retain all the record data but lose some of the special built-in web2py functionality. Anthony
Re: [web2py] Re: Ubuntu and Python3
12.04 is LTS. So the 2.7 will be on servers for a long time. We need to have web3py working till the next LTS. For development just need to create a tool or tutorial to run web2py on a virtualenv. http://zerp.ly/rochacbruno Em 26/04/2012 10:34, Francisco Costa m...@franciscocosta.com escreveu: another article http://www.wefearchange.org/2012/04/python-3-on-desktop-for-quantal-quetzal.html On Thursday, April 26, 2012 2:29:47 PM UTC+1, Francisco Costa wrote: People at Canonical are thinking on releasing the next Ubuntu (12.10) with Python3 as default. Wouldn't be nice to start developing web3py to be available in 6 months?
Re: [web2py] Re: Ubuntu and Python3
That article says that Python 2.7 will still be part of Ubuntu so there should not be a problem. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] combine Autocomplete widget and SELECT_OR_ADD_OPTION widget
Hi Brian, No problem, but just to make sure, the remix I made is a combination of web2py built-in autocomplete and since I can't make it works out of the box with SELECT_OR_ADD_OPTION, I merge both widget into a single new widget that I call : AutocompleteWidgetSelectOrAddOption So, as long as I am co-author of AutocompleteWidgetSelectOrAddOption, I am happy. Also, maybe better to make 2 slices to make sure no body get confuse and link those slices together somehow. Maybe, the best approach could be to make a single AutocompleteWidgetSelectOrAddOption that can allow to use only Autocomplete, SelectOrAddOption or both together. But It will take more refactor then I did. I could do that letter when I clean the code. Richard On Wed, Apr 25, 2012 at 8:12 PM, Brian M bmere...@gmail.com wrote: Cool Richard! I haven't done much with that widget since initially creating it. I thought that there was someone who was creating an improved version a few months ago but can't for the life of me find it anywhere. :( Feel free to send me a patch and I'll put it up in the bitbucket repo and/or update the slice! Brian
Re: [web2py] String EOF error
May help?! http://bytes.com/topic/python/answers/36704-graceful-detection-eof Richard On Wed, Apr 25, 2012 at 5:29 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi I randomly get a EOFError this doesn't always happen and I have no idea what is causing it. Traceback (most recent call last): File /home/developer/projects/yaw/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1352, in module File /home/developer/projects/yaw/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1085, in errors error = pickle.load(fullpath_file) File /usr/lib/python2.7/pickle.py, line 1378, in load return Unpickler(file).load() File /usr/lib/python2.7/pickle.py, line 858, in load dispatch[key](self) File /usr/lib/python2.7/pickle.py, line 880, in load_eof raise EOFError EOFError -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] use PAM groups for group membership decorators
On Wed, Apr 25, 2012 at 11:39 AM, Matt mbroa...@gmail.com wrote: It seems that web2py group membership is restricted to groups created by web2py. We have a situation where we are bypassing web2py's user management and using PAM directly. This works great for just logging in, but we have no access to group information because web2py is looking to its own database of user groups, rather than those of the system user. Is there an easy way to fix this? Could someone possibly give me direction on where the work needs to be done to implement this so I can get started? It seems to me that the only thing blocking me from returning the PAM groups for the auth module groups method (and related membership functionality), is the ability to determine if a user has indeed logged in through PAM or through web2py's user system. Is there a way to do this? Does it make sense to update the web2py user tables to include a login-type column? Matt
Re: [web2py] String EOF error
Yeah except this is an issue with web2py I can't even view my apps error page as I just get that message now every time.However when viewing my site normally there is no problems On Thu, Apr 26, 2012 at 7:06 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: May help?! http://bytes.com/topic/python/answers/36704-graceful-adetection-eofhttp://bytes.com/topic/python/answers/36704-graceful-detection-eof Richard On Wed, Apr 25, 2012 at 5:29 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi I randomly get a EOFError this doesn't always happen and I have no idea what is causing it. Traceback (most recent call last): File /home/developer/projects/yaw/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1352, in module File /home/developer/projects/yaw/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1085, in errors error = pickle.load(fullpath_file) File /usr/lib/python2.7/pickle.py, line 1378, in load return Unpickler(file).load() File /usr/lib/python2.7/pickle.py, line 858, in load dispatch[key](self) File /usr/lib/python2.7/pickle.py, line 880, in load_eof raise EOFError EOFError -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] String EOF error
Ok, but do you use pikled object in your app? If so, it could come from your code. There is maybe broken stuff in web2py, I saw mail passing on the list about pickle that could not work properly in newer version or in some circonstance, don't remember... I don't know I just try to help. Richard On Thu, Apr 26, 2012 at 10:28 AM, Bruce Wade bruce.w...@gmail.com wrote: Yeah except this is an issue with web2py I can't even view my apps error page as I just get that message now every time.However when viewing my site normally there is no problems On Thu, Apr 26, 2012 at 7:06 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: May help?! http://bytes.com/topic/python/answers/36704-graceful-adetection-eofhttp://bytes.com/topic/python/answers/36704-graceful-detection-eof Richard On Wed, Apr 25, 2012 at 5:29 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi I randomly get a EOFError this doesn't always happen and I have no idea what is causing it. Traceback (most recent call last): File /home/developer/projects/yaw/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1352, in module File /home/developer/projects/yaw/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1085, in errors error = pickle.load(fullpath_file) File /usr/lib/python2.7/pickle.py, line 1378, in load return Unpickler(file).load() File /usr/lib/python2.7/pickle.py, line 858, in load dispatch[key](self) File /usr/lib/python2.7/pickle.py, line 880, in load_eof raise EOFError EOFError -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] String EOF error
Maybe related : https://groups.google.com/forum/?fromgroups#!topic/web2py/3VOr81wpP94 On Thu, Apr 26, 2012 at 10:53 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: Ok, but do you use pikled object in your app? If so, it could come from your code. There is maybe broken stuff in web2py, I saw mail passing on the list about pickle that could not work properly in newer version or in some circonstance, don't remember... I don't know I just try to help. Richard On Thu, Apr 26, 2012 at 10:28 AM, Bruce Wade bruce.w...@gmail.com wrote: Yeah except this is an issue with web2py I can't even view my apps error page as I just get that message now every time.However when viewing my site normally there is no problems On Thu, Apr 26, 2012 at 7:06 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: May help?! http://bytes.com/topic/python/answers/36704-graceful-adetection-eofhttp://bytes.com/topic/python/answers/36704-graceful-detection-eof Richard On Wed, Apr 25, 2012 at 5:29 PM, Bruce Wade bruce.w...@gmail.comwrote: Hi I randomly get a EOFError this doesn't always happen and I have no idea what is causing it. Traceback (most recent call last): File /home/developer/projects/yaw/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1352, in module File /home/developer/projects/yaw/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1085, in errors error = pickle.load(fullpath_file) File /usr/lib/python2.7/pickle.py, line 1378, in load return Unpickler(file).load() File /usr/lib/python2.7/pickle.py, line 858, in load dispatch[key](self) File /usr/lib/python2.7/pickle.py, line 880, in load_eof raise EOFError EOFError -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] String EOF error
Yes I use pickle for my adviewer but that works without a problem. and we can view all pages. I will look at the link you sent now On Thu, Apr 26, 2012 at 7:54 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: Maybe related : https://groups.google.com/forum/?fromgroups#!topic/web2py/3VOr81wpP94 On Thu, Apr 26, 2012 at 10:53 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: Ok, but do you use pikled object in your app? If so, it could come from your code. There is maybe broken stuff in web2py, I saw mail passing on the list about pickle that could not work properly in newer version or in some circonstance, don't remember... I don't know I just try to help. Richard On Thu, Apr 26, 2012 at 10:28 AM, Bruce Wade bruce.w...@gmail.comwrote: Yeah except this is an issue with web2py I can't even view my apps error page as I just get that message now every time.However when viewing my site normally there is no problems On Thu, Apr 26, 2012 at 7:06 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: May help?! http://bytes.com/topic/python/answers/36704-graceful-adetection-eofhttp://bytes.com/topic/python/answers/36704-graceful-detection-eof Richard On Wed, Apr 25, 2012 at 5:29 PM, Bruce Wade bruce.w...@gmail.comwrote: Hi I randomly get a EOFError this doesn't always happen and I have no idea what is causing it. Traceback (most recent call last): File /home/developer/projects/yaw/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1352, in module File /home/developer/projects/yaw/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /home/developer/projects/yaw/applications/admin/controllers/default.py https://50.116.5.151/admin/edit/admin/controllers/default.py, line 1085, in errors error = pickle.load(fullpath_file) File /usr/lib/python2.7/pickle.py, line 1378, in load return Unpickler(file).load() File /usr/lib/python2.7/pickle.py, line 858, in load dispatch[key](self) File /usr/lib/python2.7/pickle.py, line 880, in load_eof raise EOFError EOFError -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] combine Autocomplete widget and SELECT_OR_ADD_OPTION widget
Il 26/04/2012 02:12, Brian M ha scritto: Cool Richard! I haven't done much with that widget since initially creating it. I thought that there was someone who was creating an improved version a few months ago but can't for the life of me find it anywhere. :( Feel free to send me a patch and I'll put it up in the bitbucket repo and/or update the slice! Brian if you refers to it http://code.google.com/p/web2py/issues/detail?id=716can=1q=autocomplete http://code.google.com/p/web2py/issues/detail?id=716can=1q=autocomplete I thik it was me :) the improvement was introduced in trunk by massimo. cheers Manuele
[web2py] Stats for pageviews
Hi, I like to have statistics about views of individual articles on my page. The Articles database table contain a title content and pageview field. My problem is I got no idea how to count the visitors. Thanks
[web2py] Re: Stats for pageviews
One easy way is just to add a counter field and then +1 it each time it's viewed. I do this: if not (item.seller==auth.user_id or is_bot(request)): item.update_record(views=item.views+1, modified_on=item.modified_on, modified_by=item.modified_by) I have 2 exceptions: bots like Google and if the author is viewing the page (I don't count that). You could also just rely on Google Analytics and not have to do any programming (other than inserting Google javascript into all your pages).
Re: [web2py] Re: Ubuntu and Python3
just wondering if having web3py in python 3 will give us some problem with some share hosting On Thu, Apr 26, 2012 at 2:52 PM, Johann Spies johann.sp...@gmail.comwrote: That article says that Python 2.7 will still be part of Ubuntu so there should not be a problem. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- Sebastian E. Ovide
[web2py] Re: storing objects in session
Hi Anthony, Thanks for your reply and explanation. I just need the Rows object for retrieve purposes. Kind regards, Annet.
Re: [web2py] Re: web2py: encrypt uploaded files
Hi, I think your recipe will work ;) My situation is different a bit from Naveed. My database is RDBMS, but i want to store uploaded file in a Key/Value storage(NoSQL). How can I intervent to store/retrieve process? I want to temporarily store uploaded file in memory, than call API to put this in-memory file to my Key/Value storage. (and similar when have retrieve request) Could you have me figure it out pls? Thanks in advance! On Friday, April 13, 2012 8:22:02 PM UTC+7, Massimo Di Pierro wrote: I have not tried it but you can do class EncryptedField(Field): def __init__(self,*a,**b): self.password = b['password'] del b['password'] Field.__init__(self,*a,**b) def store(self,file, filename=None, path=None): newfile = encrypt(file,self.password) return Field.store(self,file,filename,path) def retrieve(self, name, path=None): (filename, file) = Field.retrieve(self,name,path) newfile = decrypt(file,self.password) return (filename, newfile) the use db.define_table('person',Field('name'),EncryptedField('secret','upload',password='too many secrets!')) On Thursday, 12 April 2012 16:35:36 UTC-5, naveed wrote: I wasn’t asking as how to encrypt the file itself, but how to incorporate it in to web2py’s existing excellent form upload and download system. Assuming that we have functions encrypt(file, password) and decrypt(file, password) which return the encrypted and decrypted file respectively. *From:* Massimo Di Pierro massimo.dipie...@gmail.com *Sent:* Wednesday, April 11, 2012 13.31 *To:* web2py@googlegroups.com *Subject:* Re: [web2py] Re: web2py: encrypt uploaded files Perhaps this can be useful: http://stackoverflow.com/questions/6309958/encrypting-a-file-with-rsa-in-python (look at code in first answer) On Wednesday, 11 April 2012 12:35:05 UTC-5, naveed wrote: Thanks Massimo for getting back. I can’t use an encrypted file system as when the file system is mounted, it’s totally open. Every file can be encrypted with the same master password. I’m thinking of storing this master password which is itself encrypted using the user’s password (or it’s hash) in the auth_user table. On a related note, I am planning to encrypt some columns of other tables using the same master password. Your thoughts on this approach? *From:* Massimo Di Pierro massimo.dipie...@gmail.com *Sent:* Wednesday, April 11, 2012 12.13 *To:* web2py@googlegroups.com *Subject:* [web2py] Re: web2py: encrypt uploaded files What are the specs? Can you store them in an encrypted file system? can you encrypt them with the same password? Should every file be encrypted with a different password? Where should the passwords be stored? On Wednesday, 11 April 2012 11:54:24 UTC-5, naveed wrote: I need to encrypt uploaded files in web2py (for a HIPAA compliant application) preferably with AES. How can I accomplish this?
[web2py] Re: attachment;filename=%s.ics
Hi Anthony, It should also work without the extra parentheses around IS_SLUG: 'attachment;filename=event_%s_%s.ics' % (IS_SLUG()(organization.name)[0], row.id) Indeed, it does. I must have overlooked the opening and closing parentheses. Kind regards, Annet.
Re: [web2py] Re: web2py: encrypt uploaded files
Edit: I want to temporarily store uploaded file in memory, *then* call API to put this in-memory file to my Key/Value storage. When I put this in-memory file (Value) to Key/Value storage, i will get back a *Key* from it, and save this Key to RDBMS. When i want retrieve this blob, i will get this Key from RDBMS, then query Key/Value storage to get file(Value) and streaming back to browser. On Thursday, April 26, 2012 11:41:18 PM UTC+7, minhcd wrote: Hi, I think your recipe will work ;) My situation is different a bit from Naveed. My database is RDBMS, but i want to store uploaded file in a Key/Value storage(NoSQL). How can I intervent to store/retrieve process? I want to temporarily store uploaded file in memory, *then* call API to put this in-memory file to my Key/Value storage. (and similar when have retrieve request) Could you have me figure it out pls? Thanks in advance! On Friday, April 13, 2012 8:22:02 PM UTC+7, Massimo Di Pierro wrote: I have not tried it but you can do class EncryptedField(Field): def __init__(self,*a,**b): self.password = b['password'] del b['password'] Field.__init__(self,*a,**b) def store(self,file, filename=None, path=None): newfile = encrypt(file,self.password) return Field.store(self,file,filename,path) def retrieve(self, name, path=None): (filename, file) = Field.retrieve(self,name,path) newfile = decrypt(file,self.password) return (filename, newfile) the use db.define_table('person',Field('name'),EncryptedField('secret','upload',password='too many secrets!')) On Thursday, 12 April 2012 16:35:36 UTC-5, naveed wrote: I wasn’t asking as how to encrypt the file itself, but how to incorporate it in to web2py’s existing excellent form upload and download system. Assuming that we have functions encrypt(file, password) and decrypt(file, password) which return the encrypted and decrypted file respectively. *From:* Massimo Di Pierro massimo.dipie...@gmail.com *Sent:* Wednesday, April 11, 2012 13.31 *To:* web2py@googlegroups.com *Subject:* Re: [web2py] Re: web2py: encrypt uploaded files Perhaps this can be useful: http://stackoverflow.com/questions/6309958/encrypting-a-file-with-rsa-in-python (look at code in first answer) On Wednesday, 11 April 2012 12:35:05 UTC-5, naveed wrote: Thanks Massimo for getting back. I can’t use an encrypted file system as when the file system is mounted, it’s totally open. Every file can be encrypted with the same master password. I’m thinking of storing this master password which is itself encrypted using the user’s password (or it’s hash) in the auth_user table. On a related note, I am planning to encrypt some columns of other tables using the same master password. Your thoughts on this approach? *From:* Massimo Di Pierro massimo.dipie...@gmail.com *Sent:* Wednesday, April 11, 2012 12.13 *To:* web2py@googlegroups.com *Subject:* [web2py] Re: web2py: encrypt uploaded files What are the specs? Can you store them in an encrypted file system? can you encrypt them with the same password? Should every file be encrypted with a different password? Where should the passwords be stored? On Wednesday, 11 April 2012 11:54:24 UTC-5, naveed wrote: I need to encrypt uploaded files in web2py (for a HIPAA compliant application) preferably with AES. How can I accomplish this?
[web2py] Re: byday=MO versus byday=row.Day.byday
Hi Anthony, Is byday just a string? If so, how could it have a weekday and an n attribute? Yes, it is: Field('byday',length=2,default='',notnull=True,unique=True) From the python dateutil docs I learned that this: TODAY+relativedelta(weekday=FR) gives me next Friday's date. ... and this: TODAY+relativedelta(weekday=TH(+1)) next Thursday, which is today. from exposing the code: nowdate=request.now.date() nowday=request.now.weekday() for row in session.oh_rows: if nowday==row.Day.id-1: row.OpeningHours.date=nowdate else: byday=row.Day.byday row.OpeningHours.date=nowdate+relativedelta(weekday=byday) ... I learned that FR and TH apparently aren't of type string. But I haven't been able to figure out how to pass row.day.byday to relativedelta() This: TODAY+relativedelta(weekday=FR) does work for everyday except TH which is today. | If so, how could it have a weekday and an n attribute? The string cannot have a weekday attribute, and it doesn't need an n attribute does it, because it's self.weekday.n or 1 I hope I provided you with sufficient information to help me solve the problem. Kind regards, Annet
[web2py] Re: crud.create causes an id problem
I'm having a similar issue using SQLFORM. I am using a table that stores extra data for users, and I call it auth_user_extended: db.define_table('auth_user_extended', Field('auth_user', db.auth_user, readable=False, writable=False), Field('supervisor', 'boolean', label='Is Supervisor?', default=False), Field('status', 'integer', requires=IS_IN_SET(db.auth_user_extended_status_types), default=1, notnull=True), Field('legal_name', length=255, notnull=True), Field('secondary_email', length=255), Field('primary_phone', length=20), Field('secondary_phone', length=20), Field('start_date', 'datetime'), Field('end_date', 'datetime'), Field('barcode_id', length=12, notnull=True, unique=True), #requires=IS_NOT_IN_DB(db, 'auth_user_extended.barcode_id')), Field('alliance_id', length=10, default=None), # this is the user's Alliance ID. If this is None, it defaults to auth_user.username. Field('supervisor_auth_user', db.auth_user, label='User\'s Supervisor', ondelete='NO ACTION'), Field('assistant_to_auth_user', db.auth_user, label='Assistant To User', ondelete='NO ACTION'), Field('vacation_minutes', 'decimal(10,2)', default=0, requires=IS_NOT_EMPTY(), notnull=True), Field('personal_minutes', 'decimal(10,2)', default=0, requires=IS_NOT_EMPTY(), notnull=True), Field('sick_minutes', 'decimal(10,2)', default=0, requires=IS_NOT_EMPTY(), notnull=True), Field('holiday_minutes', 'decimal(10,2)', default=None), # setting this field to None makes it default to the holiday's holiday_minutes setting Field('picture', 'upload', uploadfolder=os.path.join(request.folder,'static/images/user-pictures')) ) I'm trying to use this code: form = SQLFORM(db.auth_user, row.auth_user) form.append(SQLFORM(db.auth_user_extended, row.auth_user_extended)) But I've also tried making a form for auth_user_extended by itself and I still get the same problem: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. Traceback (most recent call last): File /var/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /var/web2py/applications/bonfire/controllers/administration.py https://apps.bnl.com/admin/edit/bonfire/controllers/administration.py, line 292, in module File /var/web2py/gluon/globals.py, line 175, in lambda self._caller = lambda f: f() File applications/bonfire/modules/core.py, line 473, in f return action(*a, **b) File /var/web2py/applications/bonfire/controllers/administration.py https://apps.bnl.com/admin/edit/bonfire/controllers/administration.py, line 286, in users return update() File /var/web2py/applications/bonfire/controllers/administration.py https://apps.bnl.com/admin/edit/bonfire/controllers/administration.py, line 232, in update form.append(SQLFORM(db.auth_user_extended, row.auth_user_extended)) File /var/web2py/gluon/sqlhtml.py, line 888, in __init__ inp = self.widgets.options.widget(field, default) File /var/web2py/gluon/sqlhtml.py, line 218, in widget options = requires[0].options() File /var/web2py/gluon/validators.py, line 471, in options self.build_set() File /var/web2py/gluon/validators.py, line 458, in build_set records = self.dbset(table).select(*fields, **dd) File /var/web2py/gluon/dal.py, line 8004, in __call__ query = query._id0 File /var/web2py/gluon/dal.py, line 7165, in __getattr__ return self[key] File /var/web2py/gluon/dal.py, line 7105, in __getitem__ return dict.__getitem__(self, str(key)) KeyError: '_id' I just updated to the latest trunk and started having this issue.
[web2py] Re: byday=MO versus byday=row.Day.byday
Yes, in dateutil.relativedelta, MO, TU, etc. are weekday objects, not strings (that's why you don't put them in quotes when passing them as argument values). However, I believe the weekday argument to relativedelta() can also be an integer from 0 to 6 (0 is Monday, etc.), so maybe your byday field could store weekday integers instead of names. Anthony On Thursday, April 26, 2012 1:05:45 PM UTC-4, Annet wrote: Hi Anthony, Is byday just a string? If so, how could it have a weekday and an n attribute? Yes, it is: Field('byday',length=2,default='',notnull=True,unique=True) From the python dateutil docs I learned that this: TODAY+relativedelta(weekday=FR) gives me next Friday's date. ... and this: TODAY+relativedelta(weekday=TH(+1)) next Thursday, which is today. from exposing the code: nowdate=request.now.date() nowday=request.now.weekday() for row in session.oh_rows: if nowday==row.Day.id-1: row.OpeningHours.date=nowdate else: byday=row.Day.byday row.OpeningHours.date=nowdate+relativedelta(weekday=byday) ... I learned that FR and TH apparently aren't of type string. But I haven't been able to figure out how to pass row.day.byday to relativedelta() This: TODAY+relativedelta(weekday=FR) does work for everyday except TH which is today. | If so, how could it have a weekday and an n attribute? The string cannot have a weekday attribute, and it doesn't need an n attribute does it, because it's self.weekday.n or 1 I hope I provided you with sufficient information to help me solve the problem. Kind regards, Annet
[web2py] Add RESTful Client to Contrib
Should we add a RESTful client to web2py's contrib folder? We already have clients for XML-RPC and JSON-RPC, so maybe we should include one for REST that can handle both simple a more complex cases (like file uploads, unicode, etc). I found one that I was just about to add to a project and thought it would be good to include into web2py contrib: https://github.com/thraxil/restclient/blob/master/restclient/__init__.py
[web2py] Re: ATTENTION before upgrading to trunk....
FYI I just had a problem adding a table to an existing DB (Firebird). I think it was because my old Auth tables are incompatible with BIGINT. To make it work, I created the new table manually. For example, I had to change BIGINT to INTEGER i.e. from this: created_by BIGINT REFERENCES auth_user(id) ON DELETE CASCADE to this: created_by INTEGER REFERENCES auth_user(id) ON DELETE CASCADE Thought I would mention it. D
[web2py] Re: crud.create causes an id problem
Just a thought... if you are trying to create a new table which has a 'bigint' id, this may be incompatible if it references an existing table which has an 'integer' id. Regards, David
[web2py] Re: filename in dal
Thanks for the tip. But I do not understand the default behavior of Web2Py. I would expect to have the original file name displayed, instead of just the link named file. In order to achieve this, I take your previous typ and I adapt my DAL : db.mytable.f_sourcefile.represent = lambda rowid,row: \ A(db.mytable.f_sourcefile.retrieve(row.f_sourcefile)[0][:30], _href=URL('download', args=rowid)) Is there no easier/cleaner way ?
[web2py] Re: ATTENTION before upgrading to trunk....
Thinking more about this, an INTEGER will generally store over 2 billion records. Is the reason for updating to BIGINT due to someone having hit that limit? An inner voice is saying: Can't the person who has breached that limit be asked to create his own tables instead of giving all the rest of us the inconvenience?. I shall now replace my tin-foil hat.
Re: [web2py] combine Autocomplete widget and SELECT_OR_ADD_OPTION widget
Richard, Feel free to start your own slice make this new widget available however you see fit. If it is a new combination of the autocomplete SELECT_OR_ADD_OPTION widgets it probably is better to keep it separate. Either way I'm more than happy to mention this new widget in the other slice repo. Brian On Thursday, April 26, 2012 8:57:06 AM UTC-5, Richard wrote: Hi Brian, No problem, but just to make sure, the remix I made is a combination of web2py built-in autocomplete and since I can't make it works out of the box with SELECT_OR_ADD_OPTION, I merge both widget into a single new widget that I call : AutocompleteWidgetSelectOrAddOption So, as long as I am co-author of AutocompleteWidgetSelectOrAddOption, I am happy. Also, maybe better to make 2 slices to make sure no body get confuse and link those slices together somehow. Maybe, the best approach could be to make a single AutocompleteWidgetSelectOrAddOption that can allow to use only Autocomplete, SelectOrAddOption or both together. But It will take more refactor then I did. I could do that letter when I clean the code. Richard On Wed, Apr 25, 2012 at 8:12 PM, Brian M wrote: Cool Richard! I haven't done much with that widget since initially creating it. I thought that there was someone who was creating an improved version a few months ago but can't for the life of me find it anywhere. :( Feel free to send me a patch and I'll put it up in the bitbucket repo and/or update the slice! Brian On Thursday, April 26, 2012 8:57:06 AM UTC-5, Richard wrote: Hi Brian, No problem, but just to make sure, the remix I made is a combination of web2py built-in autocomplete and since I can't make it works out of the box with SELECT_OR_ADD_OPTION, I merge both widget into a single new widget that I call : AutocompleteWidgetSelectOrAddOption So, as long as I am co-author of AutocompleteWidgetSelectOrAddOption, I am happy. Also, maybe better to make 2 slices to make sure no body get confuse and link those slices together somehow. Maybe, the best approach could be to make a single AutocompleteWidgetSelectOrAddOption that can allow to use only Autocomplete, SelectOrAddOption or both together. But It will take more refactor then I did. I could do that letter when I clean the code. Richard On Wed, Apr 25, 2012 at 8:12 PM, Brian M wrote: Cool Richard! I haven't done much with that widget since initially creating it. I thought that there was someone who was creating an improved version a few months ago but can't for the life of me find it anywhere. :( Feel free to send me a patch and I'll put it up in the bitbucket repo and/or update the slice! Brian
[web2py] response.view html file from static
i have a file located under static folder that i want to return as view i tried this: def myfunction(): response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() but doesnt workt any ideas?
[web2py] Re: response.view html file from static
I believe view files have to be within the /views folder. Alternatively, you can manually import the parse_template function from gluon.template and pass it the approriate view path and environment, but you're probably much better off just keeping your views in the /views folder (for one thing, that will enable you to compile your views, which speeds up requests). Anthony On Thursday, April 26, 2012 3:53:31 PM UTC-4, CtrlSoft wrote: i have a file located under static folder that i want to return as view i tried this: def myfunction(): response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() but doesnt workt any ideas?
Re: [web2py] response.view html file from static
if you are on linux, try: def myfunction(): response.view = *'../* static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() response.render uses /view as root folder, so you can navigate from there. On Thu, Apr 26, 2012 at 4:53 PM, CtrlSoft zerooo...@gmail.com wrote: def myfunction(): response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] response.view html file from static
Good point. I think that should work on Windows as well. Anthony On Thursday, April 26, 2012 4:32:45 PM UTC-4, rochacbruno wrote: if you are on linux, try: def myfunction(): response.view = *'../* static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() response.render uses /view as root folder, so you can navigate from there. On Thu, Apr 26, 2012 at 4:53 PM, CtrlSoft zerooo...@gmail.com wrote: def myfunction(): response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Routes.py
error messages how to customize the error messages in html 404,405 routes.py Ovidio Marinho Falcao Neto Web Developer ovidio...@gmail.com ovidiomari...@itjp.net.br ITJP - itjp.net.br 83 8826 9088 - Oi 83 9334 0266 - Claro Brasil
Re: [web2py] Routes.py
You can find the detailed information here: https://github.com/web2py/web2py/blob/master/routes.example.py#L51 and here: http://web2py.com/books/default/chapter/29/4#Routes-on-error On Thu, Apr 26, 2012 at 5:48 PM, Ovidio Marinho ovidio...@gmail.com wrote: error messages how to customize the error messages in html 404,405 routes.py Ovidio Marinho Falcao Neto Web Developer ovidio...@gmail.com ovidiomari...@itjp.net.br ITJP - itjp.net.br 83 8826 9088 - Oi 83 9334 0266 - Claro Brasil -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Re: web2py: encrypt uploaded files
For encrypting and decrypting files using a validator works quite well. In our model we have something like: Field('data', 'upload', requires=[IS_NOT_EMPTY(), IS_LENGTH(26214400, 0, error_message=File too large.), TypeValidator(), # use libmagic to test file type AVValidator(), # run antivirus SecureValidator(KEY)], Where SecureValidator is something like: class SecureValidator: ''' Encrypts files ''' def __init__(self, phrase, error_message=Error): self.phrase = phrase self.e = error_message def __call__(self, value): # Encrypt data here prior to passing to defualt web2py store method val = buffer(value.file.read()) value.file.seek(0, os.SEEK_SET) value.file.truncate() # Remove old data val = encrypt_binary(val, phrase=self.phrase) # This is the actual encryption value.file.write(val) value.file.seek(0, os.SEEK_SET) return (value, None) Although as you can see, the files are already stored on disk prior to this method call. We also have a method for downloading the files as follows: def decrypt_download(request, db, key, chunk_size = DEFAULT_CHUNK_SIZE, attachment=True): downloads from http:///download/filename import contenttype as c if not request.args: raise HTTP(404) name = request.args[-1] items = re.compile('(?Ptable.*?)\.(?Pfield.*?)\..*')\ .match(name) if not items: raise HTTP(404) (t, f) = (items.group('table'), items.group('field')) field = db[t][f] try: (filename, stream) = field.retrieve(name) # Decrypt stream here retfile = cStringIO.StringIO() val,error = decrypt_binary(stream.read(), key) stream.close() if error: # Decryption Error encountered raise HTTP(500, error) retfile.write(str(val)) retfile.seek(0, os.SEEK_SET) except IOError: logger.error(loghelper(auth, request)+'IO error encountered when decrypting download') raise HTTP(404) response.headers['Content-Type'] = c.contenttype(name) if attachment: response.headers['Content-Disposition'] = \ attachment; filename=%s % filename logger.info(loghelper(auth, request)+'File downloaded') return response.stream(retfile, chunk_size = chunk_size, request=request) Majority of the above is replication of web2py's 'file download' method. There is probably a better way of doing this, but it seems to work well for us. Hope this helps, -- Richard On Thursday, April 26, 2012 11:50:10 AM UTC-5, minhcd wrote: Edit: I want to temporarily store uploaded file in memory, *then* call API to put this in-memory file to my Key/Value storage. When I put this in-memory file (Value) to Key/Value storage, i will get back a *Key* from it, and save this Key to RDBMS. When i want retrieve this blob, i will get this Key from RDBMS, then query Key/Value storage to get file(Value) and streaming back to browser. On Thursday, April 26, 2012 11:41:18 PM UTC+7, minhcd wrote: Hi, I think your recipe will work ;) My situation is different a bit from Naveed. My database is RDBMS, but i want to store uploaded file in a Key/Value storage(NoSQL). How can I intervent to store/retrieve process? I want to temporarily store uploaded file in memory, *then* call API to put this in-memory file to my Key/Value storage. (and similar when have retrieve request) Could you have me figure it out pls? Thanks in advance! On Friday, April 13, 2012 8:22:02 PM UTC+7, Massimo Di Pierro wrote: I have not tried it but you can do class EncryptedField(Field): def __init__(self,*a,**b): self.password = b['password'] del b['password'] Field.__init__(self,*a,**b) def store(self,file, filename=None, path=None): newfile = encrypt(file,self.password) return Field.store(self,file,filename,path) def retrieve(self, name, path=None): (filename, file) = Field.retrieve(self,name,path) newfile = decrypt(file,self.password) return (filename, newfile) the use db.define_table('person',Field('name'),EncryptedField('secret','upload',password='too many secrets!')) On Thursday, 12 April 2012 16:35:36 UTC-5, naveed wrote: I wasn’t asking as how to encrypt the file itself, but how to incorporate it in to web2py’s existing excellent form upload and download system. Assuming that we have functions encrypt(file, password) and decrypt(file, password) which return the encrypted and decrypted file respectively. *From:* Massimo Di Pierro massimo.dipie...@gmail.com *Sent:* Wednesday, April 11, 2012 13.31
Re: [web2py] Re: web2py: encrypt uploaded files
For encrypting/decrypting DB columns, we also use a validator: Ex: db.define_table('table', Field('name', 'text'), Field('host', 'text', requires = SecureValidator(symmetrickey)), Field('secret', 'text', requires = SecureValidator(symmetrickey)) ) Where SecureValidator is similar to: class SecureValidator: ''' Encrypts and decrypts data to database ''' def __init__(self, phrase, error_message=Error): self.phrase = phrase self.e = error_message def __call__(self, value): # Encrypt Data here val = encrypt_string(value, phrase=self.phrase) # Encrypt string method return (val, None) def formatter(self, value): val,err = decrypt_string(value, self.phrase) # Decrypt data if err: # Log Error: ('Error occured when decrypting data') return 'Error: %s' % err else: return val -- Richard On Wednesday, April 11, 2012 12:35:05 PM UTC-5, naveed wrote: Thanks Massimo for getting back. I can’t use an encrypted file system as when the file system is mounted, it’s totally open. Every file can be encrypted with the same master password. I’m thinking of storing this master password which is itself encrypted using the user’s password (or it’s hash) in the auth_user table. On a related note, I am planning to encrypt some columns of other tables using the same master password. Your thoughts on this approach? *From:* Massimo Di Pierro massimo.dipie...@gmail.com *Sent:* Wednesday, April 11, 2012 12.13 *To:* web2py@googlegroups.com *Subject:* [web2py] Re: web2py: encrypt uploaded files What are the specs? Can you store them in an encrypted file system? can you encrypt them with the same password? Should every file be encrypted with a different password? Where should the passwords be stored? On Wednesday, 11 April 2012 11:54:24 UTC-5, naveed wrote: I need to encrypt uploaded files in web2py (for a HIPAA compliant application) preferably with AES. How can I accomplish this?
[web2py] Re: Stats for pageviews
the is_bot(request) function is not defined. everything else works perfectly. Am Donnerstag, 26. April 2012 18:22:29 UTC+2 schrieb pbreit: One easy way is just to add a counter field and then +1 it each time it's viewed. I do this: if not (item.seller==auth.user_id or is_bot(request)): item.update_record(views=item.views+1, modified_on=item.modified_on, modified_by=item.modified_by) I have 2 exceptions: bots like Google and if the author is viewing the page (I don't count that). You could also just rely on Google Analytics and not have to do any programming (other than inserting Google javascript into all your pages).
Re: [web2py] response.view html file from static
thanks. works also on windows, http://agsystem.md/ On Thursday, April 26, 2012 11:32:45 PM UTC+3, rochacbruno wrote: if you are on linux, try: def myfunction(): response.view = *'../* static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() response.render uses /view as root folder, so you can navigate from there. On Thu, Apr 26, 2012 at 4:53 PM, CtrlSoft zerooo...@gmail.com wrote: def myfunction(): response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() -- Bruno Rocha [http://rochacbruno.com.br] On Thursday, April 26, 2012 11:32:45 PM UTC+3, rochacbruno wrote: if you are on linux, try: def myfunction(): response.view = *'../* static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() response.render uses /view as root folder, so you can navigate from there. On Thu, Apr 26, 2012 at 4:53 PM, CtrlSoft zerooo...@gmail.com wrote: def myfunction(): response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() -- Bruno Rocha [http://rochacbruno.com.br] On Thursday, April 26, 2012 11:32:45 PM UTC+3, rochacbruno wrote: if you are on linux, try: def myfunction(): response.view = *'../* static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() response.render uses /view as root folder, so you can navigate from there. On Thu, Apr 26, 2012 at 4:53 PM, CtrlSoft zerooo...@gmail.com wrote: def myfunction(): response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' return dict() -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Looking for a good beginner's guide
I am a new to programming in general and am looking for an excellent beginner's guide to web2py. This is not just for learning the framework, but also learning web programming priciples, in general. In other words, I'm not just looking for the how, but also the why. I have experience with HTML/CSS and some novice experience with Python. I've seen some examples from the Head First series for other languages and those are pretty close to what I'm looking for. Does anyone have any recommendations?
[web2py] Re: Free e-book abhout Rest API
Tks. On Tuesday, April 24, 2012 5:44:28 PM UTC-3, rochacbruno wrote: Download: http://blog.apigee.com/detail/announcement_new_ebook_on_web_api_design/ -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] web2py how to change underscore to hypens in URL
Hey All, tried this by changing map_hyphen=true in routes.py, but the change is not reflected. Anybody please let me know how can I see this change or is there any other way to change underscores to hyphen in url. Thanks,
[web2py] SQLFORM.factory Field2 depends on Field1
Okay, I want to make the second field of a SQLFORM.factory depend on what is chosen in the first field... something like this... form = SQLFORM.factory( Field('PN', requires=IS_NOT_EMPTY()), Field('Segment', requires=IS_IN_SET(['Segment1', 'Segment2'])), Field('Family', requires=IS_IN_SET(getFamilies(form.vars.Segment ... Of course I can't use form.vars.Segment until the form is submitted, so how can I accomplish this? So that the field 'Family' takes the value of the field 'Segment', does a calculation and returns the appropriate list of families. I'm super new to web programming, so I apologize in advance if this is a dumb question.
[web2py] Creating a table or a an entry in a DB from index()
Hello, I'm new to web2py and to web frameworks in general and I am trying to learn the MVC model and web2py by coding. What I'm trying to do is to have a user create tables and entries in a DB that I have defined in dv.py: *TestDB = DAL(sqlite://storage.sqlite)* Now in index() I'm trying to do as follows: * ** def index(): * * form = FORM(INPUT(_name='name', requires=IS_NOT_EMPTY()),* * INPUT(_type='submit'))* * if form.process().accepted:* * TestDB().define_table(form.vars.name, Field('testField', unique=True))* * return dict(form=form)* * **return dict(form=form)* This works (i.e. no errors) but I cannot see the created entry in appadmin. From an answer I got in StackOverflow it's because what I do in index() is not persistent. I'd like to know what is the proper way of achieving this. Thank you. Regards, Madu.
[web2py] routes.py changes not reflecting in app
I tried changing map_hyphen = True as i want to change _ to - in urls. I made changes in routes.py and router.py, but the changes are not reflecting, I even restarted server many times but bad luck. Anybody please help me. Thanks in advance
[web2py] How do I show my views code in a web2py page
Hi I would like to show some view's code in my web2py page. But the first {{}} symbols in the html generate execution instead of pure displaying (showing). I can generate decent html code from my python files, and shows in my page, but views... Thanks
[web2py] Cookies and Sessions
I'm quite new to web2py and a noob at it. I've been struggling with the difference between cookies and sessions. For what I've read the main difference is that you store cookies on the clients side and sessions on the server side, also that cookies expire and sessions get erased when you close the browser! But I have plenty of questions about them and how to use them(in web2py) *1. What can you store in them? * *I've seen till now that you can store a dict and lists in a session, and I'm having trouble using cookies but I guess text is the only thing you can store... * * * *2. When are they deleted?* *According to what I googled cookies expire after a certain time(I've seen you can set this in w2p) and sessions are deleted when you exit the browser* * * *3. Could you use cookies as temporary DB?* ***If I'm right and can only store text I guess this would be complicated, but then the question is if you can modify the expiring time so it never expires unless the user deletes it? * *I mean you could use it to store user statistics for example? This is one of the things I want to implement but having trouble doing it. Let me show you what I'm trying * * * *I first do this ** def cookieCreate(): response.cookies['cookie_test'] = 1 response.cookies['cookie_test']['expires'] = 24 * 3600 response.cookies['cookie_test']['path'] = '/' then* * if request.cookies.has_key('cookie_test'): value = request.cookies['cookie_test'].value response.cookies['cookie_prueba'] = str( 1 + int(value)) #Shouldn't this update the cookie on the clients side? else: cookieCreate() As you can see, I want to implement a sort of counter that doesn't get deleted to develop some statistics later(how many games he played for example), and don't want to have a DB yet ( I want to learn how to work with cookies)* * * *4. Where are they stored?* * ** I imagine cookies are stored where the browser decides, then why the path? and while session exists where are they stored?* * * *5. Can you store a cookie in a session and viceversa?* * * *6. If sessions have to somehow be stored at the server how do you know which one belongs to whom? Is the a unique id? * * * * * Well thank you in advance to whoever can help me, I just discovered yesterday there was this group! * * * *
[web2py] Show my views code in html as can be seen in web2py.com
Hi! I can show my python code on my home page. I had to generate from something.py to something.html, but it does not work on views code. The first {{ symbols generate error, because the web2py engine try to execute it. Thanks
Re: [web2py] Show my views code in html as can be seen in web2py.com
mycode = def function(): return 'blah' {{=CODE(mycode)}} On Wed, Apr 25, 2012 at 9:33 AM, LMisi lmi...@gmail.com wrote: Hi! I can show my python code on my home page. I had to generate from something.py to something.html, but it does not work on views code. The first {{ symbols generate error, because the web2py engine try to execute it. Thanks -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Looking for a good beginner's guide
I think web2py.com/book can be a good start. 2012/4/26 newbiedev mattyoungbloo...@gmail.com: I am a new to programming in general and am looking for an excellent beginner's guide to web2py. This is not just for learning the framework, but also learning web programming priciples, in general. In other words, I'm not just looking for the how, but also the why. I have experience with HTML/CSS and some novice experience with Python. I've seen some examples from the Head First series for other languages and those are pretty close to what I'm looking for. Does anyone have any recommendations? -- Carlos J. Costa Cientista da Computação Esp. Gestão em Telecom EL MELECH NEEMAN! אָמֵן
Re: [web2py] Looking for a good beginner's guide
http://killer-web-development.com/ On Thu, Apr 26, 2012 at 11:18 PM, Carlos Costa yamandu.co...@gmail.comwrote: I think web2py.com/book can be a good start. 2012/4/26 newbiedev mattyoungbloo...@gmail.com: I am a new to programming in general and am looking for an excellent beginner's guide to web2py. This is not just for learning the framework, but also learning web programming priciples, in general. In other words, I'm not just looking for the how, but also the why. I have experience with HTML/CSS and some novice experience with Python. I've seen some examples from the Head First series for other languages and those are pretty close to what I'm looking for. Does anyone have any recommendations? -- Carlos J. Costa Cientista da Computação Esp. Gestão em Telecom EL MELECH NEEMAN! אָמֵן -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Facebook + CAS
greetings 3 app I'm developing of which need all the login is using facebook. the point is that one of the app has N amounts of domain names and facebook is necessary to configure a domain for each system login. I happened to use CAS in this way the app welcome would serve as a central authentication and one would be configured on facebook well now ... when from the app1, I login, I jump to welcome to start session, but after session start, stays in welcome and not return to app1 if I repeat the process from app1, is an infinite redirection error from app1, I configured the following: auth = Auth (db, Auth.get_or_create_key hmac_key = (), cas_provider = 'http://127.0.0.1:8000/welcome/default/user/cas') Díaz Luis Analista Programador Facultad de Odontología UC http://www.about.me/diazluis User Linux 532223
[web2py] Re: Creating a table or a an entry in a DB from index()
I think that you could use a common table for storing user input and then have a loop in a model file for creating each new table from the stored db definition records Example: db.define_table(table_names, Field(name)) for row in db(db.table_names).select(): db.define_table(row.name, Field(my_field)) It could be possible also to use one-to-many relations for adding table fields to each new table with form input. On Thursday, April 26, 2012 11:06:47 PM UTC-3, Madu wrote: Hello, I'm new to web2py and to web frameworks in general and I am trying to learn the MVC model and web2py by coding. What I'm trying to do is to have a user create tables and entries in a DB that I have defined in dv.py: *TestDB = DAL(sqlite://storage.sqlite)* Now in index() I'm trying to do as follows: * ** def index(): * * form = FORM(INPUT(_name='name', requires=IS_NOT_EMPTY()),* * INPUT(_type='submit'))* * if form.process().accepted:* * TestDB().define_table(form.vars.name, Field('testField', unique=True))* * return dict(form=form)* * **return dict(form=form)* This works (i.e. no errors) but I cannot see the created entry in appadmin. From an answer I got in StackOverflow it's because what I do in index() is not persistent. I'd like to know what is the proper way of achieving this. Thank you. Regards, Madu.
[web2py] Re: mailing with pgp
Thanks for the effort. Sad to report that I tried this and no change. Mail still not getting sent out. Still getting message No key for signing [my_from_addr...@xyz.com] On Thursday, April 26, 2012 4:10:00 PM UTC+8, szimszon wrote: Try to replace gluon tools.py with the attachement. And you can set the gnupg home with: mail.settings.gpg_home = '/home/.../.gnupg' to where the configs and keyrings are... 2012. április 26., csütörtök 8:30:30 UTC+2 időpontban weheh a következőt írta: gpg --list-secret-keys my_from_addr...@xyz.com produces an output that indicates that the address is valid. So I know I'm using the right email address. If I purposely enter an invalid email as a test, I get an error message: gpg: error reading key: secret key not available There is a GPGKEY environmental variable that is exported and is set to a value revealed by the above --list-secret-keys command. On Thursday, April 26, 2012 11:55:36 AM UTC+8, szimszon wrote: what is the output of the gpg --list-secret-keys my_from_addr...@xyz.com command if running with web2py user? Is there any environment variable set about gpg in a shell and not in environment the web2py is running? 2012. április 26., csütörtök 1:02:40 UTC+2 időpontban weheh a következőt írta: no key for signing my_from_addr...@xyz.com On Thursday, April 26, 2012 2:29:53 AM UTC+8, szimszon wrote: What is the error message? 2012. április 25., szerda 19:28:10 UTC+2 időpontban weheh a következőt írta: Thanks szimszon. I see. The keyrings were not installed under web2py. But now they are, and unfortunately, I'm still failing out in the same place (although now I have a better idea where). The message is that there is no key for signing my_from_addr...@xyz.com, which is the mail.settings.sender setting. I tried regenerating the keys (the originals had been done by another person), but it's still not working (same error message). I think the mail code is OK. But perhaps the keys are not. What's your suggestion? On Wednesday, April 25, 2012 10:13:36 PM UTC+8, szimszon wrote: In linux web2py user's keyring is in ~web2py/.gnupg/{pubring.gpg,secring.gpg} It's the default location. If you'll sign the mail than the private key should belong to ' x...@y.com'. Can you send mail if there is no gpg in action? Is smtp working? If I get some time at night I'll look at the code... 2012. április 25., szerda 15:39:32 UTC+2 időpontban weheh a következőt írta: # this is my controller def test_mail(): Email tester mail.settings.sender = 'x...@y.com' mail.settings.server = 'z.com:587' # SMTP server mail.settings.login = 'asdf:lkjh' mail.settings.encrypt = False mail.settings.ssl = False mail.settings.tls = True mail.settings.cipher_type = 'gpg' mail.settings.sign = True mail.settings.sign_passphrase = 'foobar' msg = ''this is a test' print mail.send( to='q...@r.com', reply_to=mail.settings.sender, subject='test', message=msg, raw=True, ) redirect(URL(...)) There is no ticket thrown by running this controller. The key appears to be the right key. mail.error == None. What exactly is a keyring and how is it specified? How is it any different than mail.settings.sign_passphrase as my private key? And isn't my mail.settings.sender my public key? On Wednesday, April 25, 2012 2:50:05 PM UTC+8, szimszon wrote: Sorry for that. I have little time :( Is there anything in mail.error after the mail.send(...)? The user running web2py has a pgp keyring with the right keys? Is there any exception during mail.send? Can you post the code you are using? 2012. április 25., szerda 1:06:14 UTC+2 időpontban weheh a következőt írta: I'm running 1.99.7 and none of the arguments to mail.send are valid. All the mail variables must be set via mail.settings as far as I can tell. That said, I have all my settings in place but things still not working. I'm going to start digging into mail logs next. On Tuesday, April 24, 2012 9:45:39 PM UTC+8, szimszon wrote: I have no little time sorry, I found the original testing code I used: #!/usr/bin/env python from gluon.tools import * mail=Mail() mail.settings.server='smtp server' mail.settings.sender='sender@address' mail.settings.login='user:pass' print mail.send('rec@address','test1','sign+encrypt',cipher_type='gpg',sign_passphrase=pass for gpg key) print mail.send('rec@address','test2','sign',cipher_type='gpg',encrypt=False,sign_passphrase=pass for gpg key) print mail.send('rec@address','test3','encrypt',cipher_type='gpg',sign=False,sign_passphrase=pass for gpg key) print mail.send('rec@address','test4','no sign+no encrypt') print mail.error You need to have a trusted gpg key for rec@address in your keyring (web2py user's keyring) and for sign you need to have a private key in the
Re: [web2py] routes.py changes not reflecting in app
On Apr 26, 2012, at 7:14 AM, nav010 wrote: I tried changing map_hyphen = True as i want to change _ to - in urls. I made changes in routes.py and router.py, but the changes are not reflecting, I even restarted server many times but bad luck. Anybody please help me. Post your routes, please.
[web2py] Re: mailing with pgp
I took the additional step of checking all the mail.settings... keys and they are all set to values that look correct. I also retested the gpg --list-secret-keys my_from_addr...@xyz.com and it produces a set of codes consistent with recognizing my address. The failure is happening in this block of code in tools.py: if sign: import string core.check_version( None ) pin = string.replace( payload_in.as_string(), '\n', '\r\n' ) plain = core.Data( pin ) sig = core.Data() c = core.Context() c.set_armor( 1 ) c.signers_clear() # search for signing key for From: for sigkey in c.op_keylist_all( self.settings.sender, 1 ): # !!! THIS BLOCK OF CODE IS NEVER GETTING EXECUTED if sigkey.can_sign: c.signers_add( sigkey ) if not c.signers_enum( 0 ): # THIS IS WHERE THE ERROR MESSAGE IS GETTING GENERATED self.error = 'No key for signing [%s]' % self.settings.sender return False For some reason, c.op_keylist_all(...) is returning nothing so no signers are added to the list. I tried running this code standalone from inside a python shell and it seemed to work. Could it be an environmental variable isn't getting propagated to tools.py?
[web2py] Re: How do I show my views code in a web2py page
You could always try {{=XML('#123;#125;')}} On Thursday, April 26, 2012 8:44:43 PM UTC+8, LMisi wrote: Hi I would like to show some view's code in my web2py page. But the first {{}} symbols in the html generate execution instead of pure displaying (showing). I can generate decent html code from my python files, and shows in my page, but views... Thanks
[web2py] How to intervene in web2py's upload process(store/retrieve/stream...) to do something with uploaded file?
My database is RDBMS, but i want to store uploaded file in a Key/Value storage(NoSQL). How can I intervene to web2py's store/retrieve process? I want temporarily store uploaded file in memory, then call my API to put this in-memory file to my Key/Value storage. When I put this in-memory file(Value) to Key/Value storage, i will get back a auto-gen Key from it, then save this Key to RDBMS (*Field('file','upload') will store this Key instead of modified-uploaded-filename-on-disk *) When user want download this blob, i will get Key from RDBMS, then query Key/Value storage to get file(Value) and streaming back to user. Can you have me figure out the way to intervene in store/retrieve/stream/.. process? Thanks a lot!
[web2py] How can I combine Facebook login and regular login?
So I think I successfully implemented Facebook login. However, I have a problem combining with regular login. Because as the book stated, I did auth.settings.actions_disabled=['register','change_password','request_reset_password','profile'] so I can't use regular register/login How can I combine them together? Thank you.
[web2py] Re: How do I show my views code in a web2py page
Several options: *Pure HTML:* #123;#123;some code#125;#125; *Python string formatting:* {{='{%s}' % '{some code}'}} *Python function (defined in model or module):* def wrap(code): return '{{%s}}' % code and then in the view: {{=wrap('some code')}} *Javascript:* script jQuery(function() { jQuery('.code').html(function(index, oldhtml) { return '{'+'{'+oldhtml+'}}' }) }) /script span class='code'some code/span *Read from external file:* {{import os}} {{=open(os.path.join(request.folder, 'views/myview.html'), 'rb').read()}} You can also take advantage of the web2py CODE() helper to get nice code formatting of the template code. See http://web2py.com/books/default/chapter/29/5#Built-in-helpers. Anthony On Thursday, April 26, 2012 8:44:43 AM UTC-4, LMisi wrote: Hi I would like to show some view's code in my web2py page. But the first {{}} symbols in the html generate execution instead of pure displaying (showing). I can generate decent html code from my python files, and shows in my page, but views... Thanks
[web2py] Re: Creating a table or a an entry in a DB from index()
Thank you Alan. But the problem is that the data entered from, say index() is not available at db.py. Am I right? If a user enters entries to table table_names, will db.py see them? Are the data persistent? Also my understanding from reading the online book is that the model files are run once when starting the application. Could you tell me how I can make the for-loop run after each user enters a entry in the table? Thank you. On Friday, April 27, 2012 11:29:30 AM UTC+9, Alan Etkin wrote: I think that you could use a common table for storing user input and then have a loop in a model file for creating each new table from the stored db definition records Example: db.define_table(table_names, Field(name)) for row in db(db.table_names).select(): db.define_table(row.name, Field(my_field)) It could be possible also to use one-to-many relations for adding table fields to each new table with form input. On Thursday, April 26, 2012 11:06:47 PM UTC-3, Madu wrote: Hello, I'm new to web2py and to web frameworks in general and I am trying to learn the MVC model and web2py by coding. What I'm trying to do is to have a user create tables and entries in a DB that I have defined in dv.py: *TestDB = DAL(sqlite://storage.sqlite)* Now in index() I'm trying to do as follows: * ** def index(): * * form = FORM(INPUT(_name='name', requires=IS_NOT_EMPTY()),* * INPUT(_type='submit'))* * if form.process().accepted:* * TestDB().define_table(form.vars.name, Field('testField', unique=True))* * return dict(form=form)* * **return dict(form=form)* This works (i.e. no errors) but I cannot see the created entry in appadmin. From an answer I got in StackOverflow it's because what I do in index() is not persistent. I'd like to know what is the proper way of achieving this. Thank you. Regards, Madu.
[web2py] Re: Creating a table or a an entry in a DB from index()
But the problem is that the data entered from, say index() is not available at db.py. Am I right? If a user enters entries to table table_names, will db.py see them? Are the data persistent? Alan is suggesting that the index function would store the user input in a database table, and then the db.py model file would read that database table (on subsequent requests) and use the metadata stored there to generate the table definition for the user's table. This is one of three suggestions I made on SO: http://stackoverflow.com/questions/10317214/web2py-create-table-from-user-input/10318253#10318253. Did you try any of those solutions? Also my understanding from reading the online book is that the model files are run once when starting the application. Could you tell me how I can make the for-loop run after each user enters a entry in the table? No, model files are run on every request, not just upon starting the application (actually, there is no starting the application -- application code is simply run on each request, and only upon requests). Anthony