[web2py] Facing Trouble in Cascading drop-down with ajax
I am using the three cascading drop-down menu with the help of slices i am able to show the value in the second drop-down filtered on the first one but i am not be able to shown the value in the third drop-down filtration on the second via ajax so please help me.
[web2py] Re: How to Save Query in Session
What do you think about adding a serialization function to gluon.dal.Query? Eg, Query._as_dict() We could also get the framework to automatically invoke it when saving a Query/Expression to session. On Thursday, March 29, 2012 12:58:41 PM UTC+13, Massimo Di Pierro wrote: Let me know if you have a proposal to imporve the dal to make this easier. On Wednesday, 28 March 2012 17:29:49 UTC-5, Limedrop wrote: Sometimes that will be sufficient. The issue is how you turn _lastsql into a gluon.dal object that you can further manipulate. For example, what if you want to do this: _lastsql (db.person.name == 'John') See the slice if you need to know how to do it. On Thursday, March 29, 2012 5:59:23 AM UTC+13, Cliff wrote: Doesn't db._lastsql return a string? Can't you just save that in the session? Or is that a naive question?
[web2py] Check to delete:False
After upgrading from 1.99.2 to 1.99.7 the check to delete label has changed to check to delete: False label id=delete_record__label for=delete_recordCheck to delete:False/label Is there a reason for this? Kind regards, Annet
[web2py] time field in DAL? when I retrieve it, it gives me as nontype instead of time type.
I tried to compare by doing {{=row.start_hour request.now.time()}}br/ start_hour is defined as 'time' error : TypeError: can't compare datetime.time to NoneType How can I convert time field to be time type? so I can compare them. Also, one last question is how can I show times in different timezone? Do I need to use pypt? thank you.
[web2py] New function in trunk: Sign e-mail with X.509 certificate enhancement
If you would sign an e-mail but you do not want to include the the certificate in the e-mail just specify: mail.settings.x509_nocerts = True
[web2py] [NFiT] upload fields has a retrieve_fileproperties function
2012-03-28 22:22:19 If you seek for the uploaded file's original name or the actual location of the file in the disk now you can retrieve it by: file_prop=db.files_store.content.retrieve_fileproperties( row.content ) original_filename=file_prop['filename'] path_to_the_stored_file=file_prop['path'] Path is None if file is in DB.
[web2py] [NFiT] Sign e-mail with X.509 certificate enhancement
Version 1.99.7 (2012-03-28 22:22:19) dev 2012. március 29., csütörtök 10:52:30 UTC+2 időpontban szimszon a következőt írta: If you would sign an e-mail but you do not want to include the the certificate in the e-mail just specify: mail.settings.x509_nocerts = True
Re: [web2py] Re: sqlite to postgres
Upgrade. Python 2.7 is backward compatible with 2.6. Pip install is also a good option.
[web2py] database foreign key question
Thanks to you my project make nice progress : http://img26.imageshack.us/img26/1271/loginscreena.png But i need to know some things : here is my database : db.define_table('Skill', Field('Nom', unique=True), format = '%(Nom)s') db.define_table('SkillLevel', Field('Level', 'integer'), Field('Skill', db.Skill), Field('Parent', db.Skill), format = '%(Skill)s') and : if db(db.SkillLevel.Skill.Nom == ''toto).count() == 0: Don't work i says to me skill have no nom attribute then an other question : db.define_table('Demande', Field('Topic', unique=True), Field('Texte'), Field('Skills','list:reference SkillDemande'), Field('Items','list:reference Item'), Field('auth_user',db.auth_user), format = '%(Topic)s') db.define_table('Item', Field('Nom', unique=True), Field('SkillUse', db.SkillLevel), format = '%(Nom)s') How to select an item by Nom ? How to add an item in demande ? regards Bussiere
Re: [web2py] 2.6, 2.7, 3.2, PyPy ... wich one to use?
2012/3/29 Jonathan Lundell jlund...@pobox.com: Latest 2.7. I thought 2.5 was the recommended option for web2py. From the book: ...on Python versions 2.4, 2.5, 2.6, and 2.7, although officially it only supports 2.5 so that we can guarantee backward compatibility for applications.
[web2py] web2py icon/logo?
I want to put an icon of web2py on a poster that I am going to present. Is this icon the right choice? http://s3.amazonaws.com/uploads.uservoice.com/logo/design_setting/60411/original/web2py_icon_4162_0.png?1322778787 I dont want to use the strechted logo (http://web2py.com/examples/static/images/logo_lb.png) since it takes to much space, but I would use it if this is the official web2py icon
Re: [web2py] 2.6, 2.7, 3.2, PyPy ... wich one to use?
As far as I understand, Web2py is developed using 2.5 features. So, the framework itself officially supports v2.5 and this is good. But it doesn't mean you cannot use 2.7 to develop your application based on the framework. I, personally, always use the latest Python stable release. There's no reason to use a past one when you develop your apps. Unless you can't upgrade your production environment. -- Vinicius Assef On Thu, Mar 29, 2012 at 7:38 AM, Sergi Pons Freixes sachiel2...@gmail.com wrote: 2012/3/29 Jonathan Lundell jlund...@pobox.com: Latest 2.7. I thought 2.5 was the recommended option for web2py. From the book: ...on Python versions 2.4, 2.5, 2.6, and 2.7, although officially it only supports 2.5 so that we can guarantee backward compatibility for applications.
[web2py] Dynamically create form ?
is there a way to dynamically create a for like : liste = [titi,toto] form=FORM(UserName:, INPUT(_name='Username'), Email : , INPUT(_name='email',_value=user.email), ) for l in liste : form.add(%s : %l,INPUT(_name=%s%l)) # and at the end add the submit button : form.add(INPUT(_type='submit')) Reagrds Bussiere
[web2py] Re: Dynamically create form ?
Find i've adapted an exemple : form=FORM(UserName:, INPUT(_name='Username'), Email : , INPUT(_name='email',_value=user.email), INPUT(_type='submit')) form.insert(-1,INPUT(_name='titi',_value='titi')) the doc : Sometimes you may wish to add an extra element to your form after it has been created. For example, you may wish to add a checkbox which confirms the user agrees with the terms and conditions of your website: 1. 2. 3. 4. form = SQLFORM(db.yourtable) my_extra_element = TR(LABEL('I agree to the terms and conditions'), \ INPUT(_name='agree',value=True,_type='checkbox')) form[0].insert(-1,my_extra_element) Le jeudi 29 mars 2012 14:14:01 UTC+2, bussiere adrien a écrit : is there a way to dynamically create a for like : liste = [titi,toto] form=FORM(UserName:, INPUT(_name='Username'), Email : , INPUT(_name='email',_value=user.email), ) for l in liste : form.add(%s : %l,INPUT(_name=%s%l)) # and at the end add the submit button : form.add(INPUT(_type='submit')) Reagrds Bussiere
[web2py] Re: Dynamically create form ?
More generally, all web2py HTML helpers (including FORM and SQLFORM) act like Python lists with respect to their components, so you can use all the Python list methods, including .insert and .append. Helpers also act like Python dictionaries with respect to their attributes (i.e., named arguments), so you can used dictionary methods like .update for attributes. Subscripting works as expected as well. See http://web2py.com/books/default/chapter/29/5#HTML-helpers. Anthony On Thursday, March 29, 2012 8:30:25 AM UTC-4, bussiere adrien wrote: Find i've adapted an exemple : form=FORM(UserName:, INPUT(_name='Username'), Email : , INPUT(_name='email',_value=user.email), INPUT(_type='submit')) form.insert(-1,INPUT(_name='titi',_value='titi')) the doc : Sometimes you may wish to add an extra element to your form after it has been created. For example, you may wish to add a checkbox which confirms the user agrees with the terms and conditions of your website: 1. 2. 3. 4. form = SQLFORM(db.yourtable) my_extra_element = TR(LABEL('I agree to the terms and conditions'), \ INPUT(_name='agree',value=True,_type='checkbox')) form[0].insert(-1,my_extra_element) Le jeudi 29 mars 2012 14:14:01 UTC+2, bussiere adrien a écrit : is there a way to dynamically create a for like : liste = [titi,toto] form=FORM(UserName:, INPUT(_name='Username'), Email : , INPUT(_name='email',_value=user.email), ) for l in liste : form.add(%s : %l,INPUT(_name=%s%l)) # and at the end add the submit button : form.add(INPUT(_type='submit')) Reagrds Bussiere
Re: [web2py] 2.6, 2.7, 3.2, PyPy ... wich one to use?
I thought 2.5 was the recommended option for web2py. From the book: ...on Python versions 2.4, 2.5, 2.6, and 2.7 That's not quite correct, as 2.4 is no longer supported. although officially it only supports 2.5 so that we can guarantee backward compatibility for applications. I'm not quite sure what that's supposed to mean. Perhaps it simply means that if you develop an app targeted at 2.5, you are guaranteed to be able to run that app anywhere web2py itself can run (i.e., down to 2.5), but if you develop an app targeted at 2.7, it will only run on 2.7 (and therefore not everywhere web2py can run). If that's what is meant, it could probably be stated better. It's not really an issue of backward compatibility of the app, I think. Anthony
[web2py] Re: web2py icon/logo?
No, that's the old logo, which was replaced over a year ago -- don't use that one. The logos are at the bottom of the downloads page: http://www.web2py.com/examples/default/download. You might also consider using the web2py.com favicon, which you can find in the /static folder of the examples app that comes with web2py (see https://github.com/web2py/web2py/blob/master/applications/examples/static/favicon.ico). Anthony On Thursday, March 29, 2012 7:13:10 AM UTC-4, selecta wrote: I want to put an icon of web2py on a poster that I am going to present. Is this icon the right choice? http://s3.amazonaws.com/uploads.uservoice.com/logo/design_setting/60411/original/web2py_icon_4162_0.png?1322778787 I dont want to use the strechted logo ( http://web2py.com/examples/static/images/logo_lb.png) since it takes to much space, but I would use it if this is the official web2py icon
[web2py] Re: Web-page freezes on db.define_table
try use migrate=false to fit into legacy db. otherwise, it will try to create it. (pls refer to official doc on section: dal - legacy db) (one more hit that may not be related to this issue: define_table will create an id column automatically.) 在 2011年12月21日星期三UTC+8下午6时23分56秒,Axel写道: Hi, I have just started with web2py, setting up a simple page with MySQL. In db.py I added/changed the following: db = DAL('mysql://root:xxx@localhost:3306/test') db.define_table('testdata',Field('idtestdata'),Field('nyckel'),Field('data')) But when accessing the app I get an error ticket: Ticket ID 127.0.0.1.2011-12-21.11-11-59.27d5caca-b9cf-4f73-b3e7-4a7a61318e19 class 'gluon.contrib.pymysql.err.InternalError' (1060, uDuplicate column name 'nyckel') Shouldn't define_table create or just use the table which is already present in the database? Any suggestions are welcome. Regards, Axel
Re: [web2py] 2.6, 2.7, 3.2, PyPy ... wich one to use?
2012/3/29 20:39:38 Xiaofeng Tang fengcli...@gmail.com: Sergi Pons Freixes Wrote: 2012/3/29 Jonathan Lundell jlund...@pobox.com: Latest 2.7. I thought 2.5 was the recommended option for web2py. From the book: ...on Python versions 2.4, 2.5, 2.6, and 2.7, although officially it only supports 2.5 so that we can guarantee backward compatibility for applications. There're no much breaking changes between latest version (2.7) and 2.5.
[web2py] Versions earlier than 1.77.1?
Hello, I'm trying to find the source code for v1.61.1 but I can't seem to find anything earlier than v1.77.1 publicly available. Is there a public archive that goes back prior to v1.77.1? Thanks, Willoughby
[web2py] Re: [NFiT] upload fields has a retrieve_fileproperties function
Shouldn't it be called ..retrieve_file_properties? On Thursday, March 29, 2012 5:58:35 AM UTC-3, szimszon wrote: 2012-03-28 22:22:19 If you seek for the uploaded file's original name or the actual location of the file in the disk now you can retrieve it by: file_prop=db.files_store.content.retrieve_fileproperties( row.content ) original_filename=file_prop['filename'] path_to_the_stored_file=file_prop['path'] Path is None if file is in DB.
[web2py] Re: Check to delete:False
Looks like an error when typing or something like that. For me it should be only Check to delete On Thursday, March 29, 2012 4:49:08 AM UTC-3, Annet wrote: After upgrading from 1.99.2 to 1.99.7 the check to delete label has changed to check to delete: False label id=delete_record__label for=delete_recordCheck to delete:False/label Is there a reason for this? Kind regards, Annet
[web2py] Re: Facing Trouble in Cascading drop-down with ajax
Is your code from a web2py slice? please add the example link or post the code that is not working. On Thursday, March 29, 2012 3:31:36 AM UTC-3, Sanjeet Kumar wrote: I am using the three cascading drop-down menu with the help of slices i am able to show the value in the second drop-down filtered on the first one but i am not be able to shown the value in the third drop-down filtration on the second via ajax so please help me.
[web2py] Python Negative Popularity
The fall of the python's fault Django and Python 3.0? http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html 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
[web2py] Re: Versions earlier than 1.77.1?
Why would you want that? On Thursday, March 29, 2012 9:07:22 PM UTC+8, Willoughby wrote: Hello, I'm trying to find the source code for v1.61.1 but I can't seem to find anything earlier than v1.77.1 publicly available. Is there a public archive that goes back prior to v1.77.1? Thanks, Willoughby
[web2py] Re: Check to delete:False
SQLFORM takes delete_label and separator arguments. Previously (at least up to 1.99.2), delete_label defaulted to Check to delete:, and the separater was not appended. At some point since 1.99.2, it was changed -- now delete_label defaults to Check to delete, and separator (which defaults to : ) is appended. I think this was done (a) to correct the problem with the missing space after the : in the original label and (b) to make the separator for the delete record label consistent with the other labels. The default behavior is the same as before (except for the inclusion of the trailing space), but if you were doing something other than the default, the output could change. It looks like you might have separator=False, so False is getting appended to the label. If you just remove any explicit delete_label and separator arguments, you should get what you're looking for. Anthony which it concatenates to create the delete record label. If you set separator=False, it will On Thursday, March 29, 2012 3:49:08 AM UTC-4, Annet wrote: After upgrading from 1.99.2 to 1.99.7 the check to delete label has changed to check to delete: False label id=delete_record__label for=delete_recordCheck to delete:False/label Is there a reason for this? Kind regards, Annet
[web2py] Re: database foreign key question
For counting SkillLevels that match a Skill with name toto you can use this: if db((db.SkillLevel.Skill == db.SkillLevel.id) (db.Skill.Nom == toto)).count() == 0: Select the first item by Nom (for Nome a string): # you can make .last() or simply .select(), which will return a Rows object with # the sequence of records that match the query if found db(db.item.Nom == Nom value).select().first() Add a record to demande: db.Demande.insert(Topic=topic value, Texte=texte value, ...) On Thursday, March 29, 2012 7:20:31 AM UTC-3, bussiere adrien wrote: Thanks to you my project make nice progress : http://img26.imageshack.us/img26/1271/loginscreena.png But i need to know some things : here is my database : db.define_table('Skill', Field('Nom', unique=True), format = '%(Nom)s') db.define_table('SkillLevel', Field('Level', 'integer'), Field('Skill', db.Skill), Field('Parent', db.Skill), format = '%(Skill)s') and : if db(db.SkillLevel.Skill.Nom == ''toto).count() == 0: Don't work i says to me skill have no nom attribute then an other question : db.define_table('Demande', Field('Topic', unique=True), Field('Texte'), Field('Skills','list:reference SkillDemande'), Field('Items','list:reference Item'), Field('auth_user',db.auth_user), format = '%(Topic)s') db.define_table('Item', Field('Nom', unique=True), Field('SkillUse', db.SkillLevel), format = '%(Nom)s') How to select an item by Nom ? How to add an item in demande ? regards Bussiere
[web2py] Re: database foreign key question
Sorry the first query was wrong: if db((db.SkillLevel.Skill == db.Skill.id http://db.skilllevel.id/) (db.Skill.Nom == toto)).count() == 0: On Thursday, March 29, 2012 11:01:14 AM UTC-3, Alan Etkin wrote: For counting SkillLevels that match a Skill with name toto you can use this: if db((db.SkillLevel.Skill == db.SkillLevel.id) (db.Skill.Nom == toto)).count() == 0: Select the first item by Nom (for Nome a string): # you can make .last() or simply .select(), which will return a Rows object with # the sequence of records that match the query if found db(db.item.Nom == Nom value).select().first() Add a record to demande: db.Demande.insert(Topic=topic value, Texte=texte value, ...) On Thursday, March 29, 2012 7:20:31 AM UTC-3, bussiere adrien wrote: Thanks to you my project make nice progress : http://img26.imageshack.us/img26/1271/loginscreena.png But i need to know some things : here is my database : db.define_table('Skill', Field('Nom', unique=True), format = '%(Nom)s') db.define_table('SkillLevel', Field('Level', 'integer'), Field('Skill', db.Skill), Field('Parent', db.Skill), format = '%(Skill)s') and : if db(db.SkillLevel.Skill.Nom == ''toto).count() == 0: Don't work i says to me skill have no nom attribute then an other question : db.define_table('Demande', Field('Topic', unique=True), Field('Texte'), Field('Skills','list:reference SkillDemande'), Field('Items','list:reference Item'), Field('auth_user',db.auth_user), format = '%(Topic)s') db.define_table('Item', Field('Nom', unique=True), Field('SkillUse', db.SkillLevel), format = '%(Nom)s') How to select an item by Nom ? How to add an item in demande ? regards Bussiere
[web2py] Re: Python Negative Popularity
I'm not convinced that the stats you cite about Python are statistically meaningful over a one-year period (2.45% decline?). But it seems to me that on the web the key issue is browser integration. JavaScript is the default language of the web because browsers all interpret it internally. PHP, you'll notice, also saw a small decline in these stats. I think that's related to the desire to do as much as possible in the browser (client-side). As long as that is the push, and as long as Python doesn't have client-side support built-in, it will always be in a second-class position on the web. I actually think that one of the strengths of Python is that it doesn't have to run on a server--it can work equally well with a native local interpreter. But so far in web development we have treated it as a drop-in replacement for PHP (and so as server-dependent) rather than as a language to run locally on the client. That said, I think the expansion of the Python web ecosystem beyond Django can't but help the language's profile. This is not to slam Django, but as long as a language is perceived as a one-framework show (like Ruby and rails) it will tend to have trouble making converts. Ian On Thursday, March 29, 2012 9:42:08 AM UTC-4, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0? http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html 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] Re: Python Negative Popularity
I believe in what you speak. 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 2012/3/29 monotasker scotti...@gmail.com I'm not convinced that the stats you cite about Python are statistically meaningful over a one-year period (2.45% decline?). But it seems to me that on the web the key issue is browser integration. JavaScript is the default language of the web because browsers all interpret it internally. PHP, you'll notice, also saw a small decline in these stats. I think that's related to the desire to do as much as possible in the browser (client-side). As long as that is the push, and as long as Python doesn't have client-side support built-in, it will always be in a second-class position on the web. I actually think that one of the strengths of Python is that it doesn't have to run on a server--it can work equally well with a native local interpreter. But so far in web development we have treated it as a drop-in replacement for PHP (and so as server-dependent) rather than as a language to run locally on the client. That said, I think the expansion of the Python web ecosystem beyond Django can't but help the language's profile. This is not to slam Django, but as long as a language is perceived as a one-framework show (like Ruby and rails) it will tend to have trouble making converts. Ian On Thursday, March 29, 2012 9:42:08 AM UTC-4, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0?ht** tp://www.tiobe.com/index.php/**content/paperinfo/tpci/index.**htmlhttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html 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
[web2py] Re: [NFiT] upload fields has a retrieve_fileproperties function
Sent a patch to google code: http://code.google.com/p/web2py/issues/detail?id=742 2012. március 29., csütörtök 15:32:01 UTC+2 időpontban Alan Etkin a következőt írta: Shouldn't it be called ..retrieve_file_properties? On Thursday, March 29, 2012 5:58:35 AM UTC-3, szimszon wrote: 2012-03-28 22:22:19 If you seek for the uploaded file's original name or the actual location of the file in the disk now you can retrieve it by: file_prop=db.files_store.content.retrieve_fileproperties( row.content ) original_filename=file_prop['filename'] path_to_the_stored_file=file_prop['path'] Path is None if file is in DB.
[web2py] Re: web2py icon/logo?
thanks i thought so, I like the fav icon because of its compact format, unfortunately my poster will be in A0 so it will probably not be my choice, it would be nice if there would be a SVG version of the fac icon for these kind of purposes. I could do it, all I would need to know for that is the font that was used :D On Thursday, March 29, 2012 2:57:09 PM UTC+2, Anthony wrote: No, that's the old logo, which was replaced over a year ago -- don't use that one. The logos are at the bottom of the downloads page: http://www.web2py.com/examples/default/download. You might also consider using the web2py.com favicon, which you can find in the /static folder of the examples app that comes with web2py (see https://github.com/web2py/web2py/blob/master/applications/examples/static/favicon.ico ). Anthony On Thursday, March 29, 2012 7:13:10 AM UTC-4, selecta wrote: I want to put an icon of web2py on a poster that I am going to present. Is this icon the right choice? http://s3.amazonaws.com/uploads.uservoice.com/logo/design_setting/60411/original/web2py_icon_4162_0.png?1322778787 I dont want to use the strechted logo ( http://web2py.com/examples/static/images/logo_lb.png) since it takes to much space, but I would use it if this is the official web2py icon
[web2py] Scheduler not working on 1.99.4 do I need to upgrade?
Do I need to upgrade? I have commented out all the code in the task definition and I still get the error. Stack trace ##3 Traceback (most recent call last): File /media/Myfiles/3-o/gluon/scheduler.py, line 158, in executor args = loads(task.args) File /media/Myfiles/3-o/gluon/contrib/simplejson/__init__.py, line 386, in loads return _default_decoder.decode(s) File /media/Myfiles/3-o/gluon/contrib/simplejson/decoder.py, line 403, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File /media/Myfiles/3-o/gluon/contrib/simplejson/decoder.py, line 419, in raw_decode obj, end = self.scan_once(s, idx) File /media/Myfiles/3-o/gluon/contrib/simplejson/scanner.py, line 72, in scan_once return _scan_once(string, idx) File /media/Myfiles/3-o/gluon/contrib/simplejson/scanner.py, line 45, in _scan_once return parse_array((string, idx + 1), _scan_once) File /media/Myfiles/3-o/gluon/contrib/simplejson/decoder.py, line 287, in JSONArray raise JSONDecodeError(Expecting object, s, end) JSONDecodeError: Expecting object: line 1 column 1 (char 1) # task definition# # note all functional code has been commented out # models/workers.py # -*- coding: utf-8 -*- from scheduler import Scheduler def do_document_package(package_id, varlist, folder_): pass ##import uno, os, socket, string # bla bla myscheduler = Scheduler(db, dict(do_document_package=do_document_package)) # controller #33 if form.process().accepted: task_name = 'process_package_' + str(request.args(0)) var_list = {} for k, v in form.vars.iteritems(): var_list[k] = v folder_ = str(request.folder) db.scheduler_task.insert( status='QUEUED', application_name='operations', task_name=task_name, function_name='do_document_package', args='[int(request.args(0)), var_list, folder_]', vars={}, enabled=True, start_time = request.now, stop_time = request.now+datetime.timedelta(days=1), repeats = 1, # run 10 times period = 3600, # every 1h timeout = 300, # should take less than 5 minutes ) response.flash = 'Processing document package.'
[web2py] Tracking/Tracing actions
Hello, I am working on a secure documentation system that should support file uploads but also to give the ability to trace user actions like download/upload of files. This should be integrated in the portal itself so that the administrator doesn't need to parse web log files and trace users and IP's. Example: user Malkovich submitted a file: report.docx with hash: 102310239123123 at 2012.03.27 10:12:45 (GMT) user BigFatCat downloaded the file: report.docx (id: 1201010121) at 2012.03.27 12:11:05 (GMT) ... So, I just said what I have and I want, so now let me tell have I done about this: in the model: ... db.define_table('attachment', Field('name', requires=IS_NOT_EMPTY()), Field('filename'), Field('description'), Field('doc_type', requires=IS_IN_SET(['text','report','image','other']), default='other'), Field('hash', 'string'), Field('file','upload'), format='%(name)s') db.define_table('logs', Field('message','string', requires=IS_NOT_EMPTY()), Field('full_description','text'), Field('action', 'string', requires=IS_IN_SET(['create','remove','download','upload', 'edit','other']),default='download'), Field('attachments', 'list:reference attachment', notnull=False), Field('user', 'list:reference auth_user'), Field('happened_on','datetime', default=datetime.datetime.now())) ... in the controller: def hash(file): return hashlib.md5(open(file).read()).hexdigest() @auth.requires_login() def insert_file(): form = SQLFORM(db.attachment, upload=URL('download'), fields=['name', 'description', 'file']) if request.vars.file!=None: form.vars.filename = request.vars.file.filename # not sure about this one... form.vars.hash = hash(file) if form.process().accepted: db.logs.insert(message='file submitted', full_description=forn.vars.hash, action='upload', attachments='', user=auth.user.id, happened_on=request.now) response.flash = 'form accepted' elif form.errors: response.flash = 'something went wrong, try harder' record = db.attachment(request.args(0)) or redirect(URL('index')) return dict(form=form) ... This is not yet working but don't think I am on the right track? Tips? Thank you
[web2py] Re: Check to delete:False
Hi Alan and Anthony, I upgraded to 1.99.7 from 1.99.2 to solve my represent problem, to solve the check to delete problem I had to change separator=False to separator='' @Anthony, thanks for your explanation. Seems like I chose the wrong solution on 02/08/2011 to solve the colon problem in SQLFORM. Kind regards, Annet
[web2py] Re: Versions earlier than 1.77.1?
I have an internally used system that was built on that version and has run several years on it. Unfortunately the code blows up with current web2py - something about 'updateable' views no longer being allowed. Also unfortunately the original team didn't use source control - so I don't have a clean copy of the original web2py code to work with. On Thursday, March 29, 2012 9:46:01 AM UTC-4, lyn2py wrote: Why would you want that? On Thursday, March 29, 2012 9:07:22 PM UTC+8, Willoughby wrote: Hello, I'm trying to find the source code for v1.61.1 but I can't seem to find anything earlier than v1.77.1 publicly available. Is there a public archive that goes back prior to v1.77.1? Thanks, Willoughby
Re: [web2py] 2.6, 2.7, 3.2, PyPy ... wich one to use?
BTW , anyone knows if pypy works with web2py? I cant get it working. On Thu, Mar 29, 2012 at 7:12 PM, Xiaofeng Tang fengcli...@gmail.com wrote: 2012/3/29 20:39:38 Xiaofeng Tang fengcli...@gmail.com: Sergi Pons Freixes Wrote: 2012/3/29 Jonathan Lundell jlund...@pobox.com: Latest 2.7. I thought 2.5 was the recommended option for web2py. From the book: ...on Python versions 2.4, 2.5, 2.6, and 2.7, although officially it only supports 2.5 so that we can guarantee backward compatibility for applications. There're no much breaking changes between latest version (2.7) and 2.5.
Re: [web2py] Re: web2py icon/logo?
In download page there is s link to download the artwork in .png high resolution. http://zerp.ly/rochacbruno Em 29/03/2012 11:57, selecta gr...@delarue-berlin.de escreveu: thanks i thought so, I like the fav icon because of its compact format, unfortunately my poster will be in A0 so it will probably not be my choice, it would be nice if there would be a SVG version of the fac icon for these kind of purposes. I could do it, all I would need to know for that is the font that was used :D On Thursday, March 29, 2012 2:57:09 PM UTC+2, Anthony wrote: No, that's the old logo, which was replaced over a year ago -- don't use that one. The logos are at the bottom of the downloads page: http://www.web2py.com/examples/default/download. You might also consider using the web2py.com favicon, which you can find in the /static folder of the examples app that comes with web2py (see https://github.com/web2py/web2py/blob/master/applications/examples/static/favicon.ico ). Anthony On Thursday, March 29, 2012 7:13:10 AM UTC-4, selecta wrote: I want to put an icon of web2py on a poster that I am going to present. Is this icon the right choice? http://s3.amazonaws.com/uploads.uservoice.com/logo/design_setting/60411/original/web2py_icon_4162_0.png?1322778787 I dont want to use the strechted logo ( http://web2py.com/examples/static/images/logo_lb.png) since it takes to much space, but I would use it if this is the official web2py icon
[web2py] Re: Versions earlier than 1.77.1?
Unfortunately the code blows up with current web2py - something about 'updateable' views no longer being allowed. What does updateable views mean? Are you talking about generic views? If so, they can be enabled via the following in a model file: response.generic_patterns = ['*'] Though for security reasons, it's not recommended to be quite so liberal with allowing generic views. See http://web2py.com/books/default/chapter/29/10#Generic-views. If that's not the issue, have you actually tried version 1.77 (or other later versions) -- even if you app doesn't work with 1.99, it might work with some other earlier version. Anyway, perhaps Massimo has older versions available somewhere. Anthony
Re: [web2py] 2.6, 2.7, 3.2, PyPy ... wich one to use?
works for me on windows, but first was needed to put a copy of sqlite dll in the pypy folder
Re: [web2py] SQLFORM.grid not doing what I want :)
When you say I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk what do you mean by manipulates? On Wednesday, 28 March 2012 22:58:31 UTC-5, Gwayne aka Mike Veltman wrote: Gentle people, I have the following grid: query = ( (db.lvdisksetup.lvgroupname_id == usedlvdisksetup) ( db.lvgroupname.id == usedlvdisksetup) (db.lvdisksetup.lvdisk_id == db.lvdisk.id) ) fields = [db.lvdisksetup.id, db.lvgroupname.lvgroupnamedesc , db.lvdisk.lvdiskdesc, db.lvdisksetup.lunid] form = SQLFORM.grid(query, fields=fields, orderby=['lvdisksetup.lunid'], csv=False, create = False, maxtextlength=45 ) I want to manipulate db.lvdisksetup but in stead it manipulates db.lvdisk :-) What causes havoc by deleting essential table data :) Part of the db models :) # All the LV sizes will be collected in here in bytes, like 30GB, 10GB, 2GB etc db.define_table('lvsize', Field('sizename', type='string', unique=True, label=T('Lun Size')), Field('size', type='string', label=T('LV Size in bytes')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # The LV Disk groups db.define_table('lvgroupname', Field('lvgroupnamedesc', type='string', unique=True, label=T('LV Disk Groupname ')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvgroupname.lvgroupnamedesc.requires = IS_NOT_EMPTY() # Logical volume on storage db.define_table('lvdisk', Field('lvdiskdesc', type='string', unique=True, label=T('LV Disk description ')), Field('lvsize_id', db.lvsize, default=2, label=T('Size ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisk.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename') db.lvdisk.lvdiskdesc.requires = IS_NOT_EMPTY() # lvdisksetup db.define_table('lvdisksetup', Field('lvdisk_id', db.lvdisk, default=1, label=T('Logical volume to be added')), Field('lvgroupname_id', db.lvgroupname, default=1, label=T('Member of Logical volume group name')), Field('lunid', type='integer', default=2, label=T('Lun ID')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.lvdisksetup.lvdisk_id.requires = IS_IN_DB(db, 'lvdisk.id', 'lvdisk.lvdiskdesc') db.lvdisksetup.lvgroupname_id.requires = IS_IN_DB(db, 'lvgroupname.id', 'lvgroupname.lvgroupnamedesc') # hbahostgroupsetup (to add the right disks to a hba or a hostgroup) db.define_table('hbahostgroupsetup', Field('hbahgdesc', type='string', label=T('LV Disk setup Description ')), Field('lvgroupname_id', db.lvgroupname, default=1, label=T('LV Disk')), Field('mapping_id', db.storagemap, default=1, label=T('HBA or Hostgroup mapping')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False), Field('modified_on','datetime',default=request.now, label=T('Modified On'),writable=False,readable=False, update=request.now), migrate=settings.migrate) # Table rules db.hbahostgroupsetup.lvgroupname_id.requires = IS_IN_DB(db, ' lvgroupname.id', 'lvdisk.lvgroupnamedesc') db.hbahostgroupsetup.mapping_id.requires = IS_IN_DB(db, 'storagemap.id', 'storagemap.mapping') db.hbahostgroupsetup.hbahgdesc.requires = IS_NOT_EMPTY() # disksetupname (to make it possible to have the same lv setup for different class setups) db.define_table('disksetupname', Field('disksetupnamedesc', type='string', label=T('LV Disk group selection description ')), Field('created_on','datetime',default=request.now, label=T('Created On'),writable=False,readable=False),
[web2py] Re: How to Save Query in Session
I think it would be nice to have a way to serialize DAL queries. The problem is should the serialization be database dependent or not. If database dependent it is easy because we can just store the SQL. Yet it would not work for noSQL. My dream has always be to have a non-database-dependent serialization. This would allow creation of a proxy adapter so that two instances of DAL can query each other. On Thursday, 29 March 2012 02:23:29 UTC-5, Limedrop wrote: What do you think about adding a serialization function to gluon.dal.Query? Eg, Query._as_dict() We could also get the framework to automatically invoke it when saving a Query/Expression to session. On Thursday, March 29, 2012 12:58:41 PM UTC+13, Massimo Di Pierro wrote: Let me know if you have a proposal to imporve the dal to make this easier. On Wednesday, 28 March 2012 17:29:49 UTC-5, Limedrop wrote: Sometimes that will be sufficient. The issue is how you turn _lastsql into a gluon.dal object that you can further manipulate. For example, what if you want to do this: _lastsql (db.person.name == 'John') See the slice if you need to know how to do it. On Thursday, March 29, 2012 5:59:23 AM UTC+13, Cliff wrote: Doesn't db._lastsql return a string? Can't you just save that in the session? Or is that a naive question?
[web2py] Re: time field in DAL? when I retrieve it, it gives me as nontype instead of time type.
default_time = datetime.time(12,00) (row.start_hour or default_time) request.now.time() On Thursday, 29 March 2012 02:50:12 UTC-5, Kenny wrote: I tried to compare by doing {{=row.start_hour request.now.time()}}br/ start_hour is defined as 'time' error : TypeError: can't compare datetime.time to NoneType How can I convert time field to be time type? so I can compare them. Also, one last question is how can I show times in different timezone? Do I need to use pypt? thank you.
[web2py] Re: Dynamically create form ?
yes. A helper (a FORM) acts as a list. You can append(), insert() and del its elements. So this: form.add(%s : %l,INPUT(_name=%s%l)) Should probably be form.append(SPAN(LABEL(I),:,INPUT(_name=l))) On Thursday, 29 March 2012 07:14:01 UTC-5, bussiere adrien wrote: is there a way to dynamically create a for like : liste = [titi,toto] form=FORM(UserName:, INPUT(_name='Username'), Email : , INPUT(_name='email',_value=user.email), ) for l in liste : form.add(%s : %l,INPUT(_name=%s%l)) # and at the end add the submit button : form.add(INPUT(_type='submit')) Reagrds Bussiere
[web2py] Re: Python Negative Popularity
I believe the non-backward compatibility of Python 3.0 and the monopolization of major conferences by Django (which was great 5 years ago but it loses to most of the other frameworks by now) are part of the cause. The other cause I think the raise of multi core processors. Python does not handle them well. The only option is multi-process applications but their are not very easy to write. This is not a problem for web applications. I also think the drop to be significant although not necessarily a long term trend. Python could rebound easily by: - extending the life of 2.x with 2.8 (including as much goodies from 3.x as possible but backward compatibility) and promising LTS - merging stackles and/or gevent - including a standard request/response objects in the libraries - include the request library as replacement for urlib/urlib2 - provide a windows distribution which includes PIL/NumPi/SciPy and is not commercial - stop the Django community from monopolizing every forum (it is still losing to Rails and therefore not the future) and emphasize diversity. - stop the purists who do bash Python projects that are working and popular for not being Pythonic (whatever it means, you do not hear of Java projects not being Javonic). - go back to target schools. I was at PyCon and it is mostly a recruiting place where consultants advertise themselves and their companies. Very few talks are technical. Meanwhile many schools are moving away from Python in favor of JavaScript. This makes no sense to me but perhaps there is something that can be done. Massimo On Thursday, 29 March 2012 08:42:08 UTC-5, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0? http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
[web2py] Re: Versions earlier than 1.77.1?
The earliest I have is 1.80.1. Yet, it should work with the latest. Send me the error you get and I will be happy to take a look. Massimo On Thursday, 29 March 2012 10:46:20 UTC-5, Anthony wrote: Unfortunately the code blows up with current web2py - something about 'updateable' views no longer being allowed. What does updateable views mean? Are you talking about generic views? If so, they can be enabled via the following in a model file: response.generic_patterns = ['*'] Though for security reasons, it's not recommended to be quite so liberal with allowing generic views. See http://web2py.com/books/default/chapter/29/10#Generic-views. If that's not the issue, have you actually tried version 1.77 (or other later versions) -- even if you app doesn't work with 1.99, it might work with some other earlier version. Anyway, perhaps Massimo has older versions available somewhere. Anthony
[web2py] Using routes.py as a dispatcher for URL shortener app
hi all, So I am coding a little app that acts as a sort of url shortener (like bit.ly). Visiting *myapp.com/tcgata* will search my database for an URL linked to ' tcgata' My reading of the documentation suggests that this can be achieved using pattern-based URL rewriting in routes.py. As such I made the following file: routes_in = ( ('.*[a-zA-Z0-9]{6}', '/catchAll'), ) #in default.py def catchAll():pass where catchAll is a controller function that will glean the search string ('tcgata') from the request object and redirect to the relevant URL (or 404 if not found). Currently it is a passed function. However, the redirection doesn't seem to be working for me. When I visit myapp.com/tcgata i get an error page saying *'invalid function (default/tcgata)'*. Where am I going wrong? Is it a routing issue? a regex issue? I am sure it is something simple I am missing, but I think I need some extra eyes to find it. Furthermore, if there is an easier way to do what I am seeing to achieve, I am all ears! thanks in advance Simon
Re: [web2py] Re: Python Negative Popularity
My only fear would be a discontinuity in python research with advances in processors andthere'd be a hands tied. 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 2012/3/29 Massimo Di Pierro massimo.dipie...@gmail.com I believe the non-backward compatibility of Python 3.0 and the monopolization of major conferences by Django (which was great 5 years ago but it loses to most of the other frameworks by now) are part of the cause. The other cause I think the raise of multi core processors. Python does not handle them well. The only option is multi-process applications but their are not very easy to write. This is not a problem for web applications. I also think the drop to be significant although not necessarily a long term trend. Python could rebound easily by: - extending the life of 2.x with 2.8 (including as much goodies from 3.x as possible but backward compatibility) and promising LTS - merging stackles and/or gevent - including a standard request/response objects in the libraries - include the request library as replacement for urlib/urlib2 - provide a windows distribution which includes PIL/NumPi/SciPy and is not commercial - stop the Django community from monopolizing every forum (it is still losing to Rails and therefore not the future) and emphasize diversity. - stop the purists who do bash Python projects that are working and popular for not being Pythonic (whatever it means, you do not hear of Java projects not being Javonic). - go back to target schools. I was at PyCon and it is mostly a recruiting place where consultants advertise themselves and their companies. Very few talks are technical. Meanwhile many schools are moving away from Python in favor of JavaScript. This makes no sense to me but perhaps there is something that can be done. Massimo On Thursday, 29 March 2012 08:42:08 UTC-5, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0?ht** tp://www.tiobe.com/index.php/**content/paperinfo/tpci/index.**htmlhttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
[web2py] Re: Python Negative Popularity
I'm not an expert in statistics but 2.45% decline is a lot because that relates to the whole language ecosystem. If you look at the numbers specific to Python, it means a drop from ~7% to ~3% which is about 50% decrease concerning what Python was a year ago. Now, this a metric, it's value,it's meaning and importance are something else. I know in a web2py group we are easily interpreted as biased but Massimo is very right on the constraint of Python to Django. Not technically because Python is probably the language with more alternatives on this but politically. The multicore advancement is not a Python specific problem. While python may not be prepared for that from scratch it is as well prepared (or better) when compared to its competitors. Also, Erlang and Scala are still a long way from becoming major choices. Finally, Javascript is winning everyday more steam. It's one those causes where programming languages are not there to help programmers, it's programmers that are helping them ;) On Thursday, 29 March 2012 17:26:48 UTC+1, Massimo Di Pierro wrote: I believe the non-backward compatibility of Python 3.0 and the monopolization of major conferences by Django (which was great 5 years ago but it loses to most of the other frameworks by now) are part of the cause. The other cause I think the raise of multi core processors. Python does not handle them well. The only option is multi-process applications but their are not very easy to write. This is not a problem for web applications. I also think the drop to be significant although not necessarily a long term trend. Python could rebound easily by: - extending the life of 2.x with 2.8 (including as much goodies from 3.x as possible but backward compatibility) and promising LTS - merging stackles and/or gevent - including a standard request/response objects in the libraries - include the request library as replacement for urlib/urlib2 - provide a windows distribution which includes PIL/NumPi/SciPy and is not commercial - stop the Django community from monopolizing every forum (it is still losing to Rails and therefore not the future) and emphasize diversity. - stop the purists who do bash Python projects that are working and popular for not being Pythonic (whatever it means, you do not hear of Java projects not being Javonic). - go back to target schools. I was at PyCon and it is mostly a recruiting place where consultants advertise themselves and their companies. Very few talks are technical. Meanwhile many schools are moving away from Python in favor of JavaScript. This makes no sense to me but perhaps there is something that can be done. Massimo On Thursday, 29 March 2012 08:42:08 UTC-5, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0? http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
[web2py] Re: Versions earlier than 1.77.1?
The earliest I have is 1.80.1. The downloads at http://web2py.com/examples/static/1.80.1/web2py_src.zip go back to 1.80.1. Google Code goes back to 1.77.1: http://code.google.com/p/web2py/source/browse/?name=R-1.77.1. Anthony
[web2py] wb2py with existing database
All, Is it possible to have the DAL create/discover models from an existing DB (without providing the schema)? If so, how would I go about making sure the models are created? Thanks in advance.
[web2py] Re: wb2py with existing database
Check out this script: http://code.google.com/p/web2py/source/browse/scripts/extract_pgsql_models.py. You may need to adapt it slightly for your particular database. Anthony On Thursday, March 29, 2012 1:14:56 PM UTC-4, rdodev wrote: All, Is it possible to have the DAL create/discover models from an existing DB (without providing the schema)? If so, how would I go about making sure the models are created? Thanks in advance.
Re: [web2py] Re: wb2py with existing database
Let me check it out. Looks promising. On Thu, Mar 29, 2012 at 1:18 PM, Anthony abasta...@gmail.com wrote: Check out this script: http://code.google.com/p/web2py/source/browse/scripts/extract_pgsql_models.py. You may need to adapt it slightly for your particular database. Anthony On Thursday, March 29, 2012 1:14:56 PM UTC-4, rdodev wrote: All, Is it possible to have the DAL create/discover models from an existing DB (without providing the schema)? If so, how would I go about making sure the models are created? Thanks in advance.
[web2py] Re: Versions earlier than 1.77.1?
Thanks for the help! Traceback below. Accounts is a view on my SQLServer DB. Looking at it, wonder if it's a difference in PYODBC versions between prod and my desktop. Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 205, in restricted exec ccode in environment File C:/web2py/applications/TheReckoning/controllers/accounts.py http://127.0.0.1:8000/admin/default/edit/TheReckoning/controllers/accounts.py, line 60, in module File C:\web2py\gluon\globals.py, line 173, in lambda self._caller = lambda f: f() File C:/web2py/applications/TheReckoning/controllers/accounts.py http://127.0.0.1:8000/admin/default/edit/TheReckoning/controllers/accounts.py, line 28, in account_detail if form.accepts(request.vars,session) : File C:\web2py\gluon\sqlhtml.py, line 1272, in accepts self.table._db(self.table._id == self.record[self.id_field_name]).update(**fields) File C:\web2py\gluon\dal.py, line 7591, in update return self.db._adapter.update(tablename,self.query,fields) File C:\web2py\gluon\dal.py, line 1116, in update self.execute(sql) File C:\web2py\gluon\dal.py, line 1392, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1386, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: ('42000', [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]View or function 'Accounts' is not updatable because the modification affects multiple base tables. (4405) (SQLExecDirectW)) On Thursday, March 29, 2012 12:30:20 PM UTC-4, Massimo Di Pierro wrote: The earliest I have is 1.80.1. Yet, it should work with the latest. Send me the error you get and I will be happy to take a look. Massimo On Thursday, 29 March 2012 10:46:20 UTC-5, Anthony wrote: Unfortunately the code blows up with current web2py - something about 'updateable' views no longer being allowed. What does updateable views mean? Are you talking about generic views? If so, they can be enabled via the following in a model file: response.generic_patterns = ['*'] Though for security reasons, it's not recommended to be quite so liberal with allowing generic views. See http://web2py.com/books/default/chapter/29/10#Generic-views. If that's not the issue, have you actually tried version 1.77 (or other later versions) -- even if you app doesn't work with 1.99, it might work with some other earlier version. Anyway, perhaps Massimo has older versions available somewhere. Anthony
[web2py] Re: Using routes.py as a dispatcher for URL shortener app
Having recently completed my own personal URL shortener app on web2py, the trick was using pattern based routes at the root level. Actually, even for a fairly complex work-related app we had to use the root-level routes.py as well. Specially with an URL shortener, you want to have the URL as small as possible (else it sorta defeats the purpose), so you are going to need something along the lines of: routes_in = ( (r'^/?$', r'/app_name/default/index'), (r'^/(?Purl[^/]*)/?$', r'/app_name/default/index/\gurl'), ) in your root-level routes.py The drawback is that you will lose access to all other apps (including admin) but that can be a good thing for public deployments. On Thursday, March 29, 2012 12:40:16 PM UTC-4, Simon Bushell wrote: hi all, So I am coding a little app that acts as a sort of url shortener (like bit.ly). Visiting *myapp.com/tcgata* will search my database for an URL linked to ' tcgata' My reading of the documentation suggests that this can be achieved using pattern-based URL rewriting in routes.py. As such I made the following file: routes_in = ( ('.*[a-zA-Z0-9]{6}', '/catchAll'), ) #in default.py def catchAll():pass where catchAll is a controller function that will glean the search string ('tcgata') from the request object and redirect to the relevant URL (or 404 if not found). Currently it is a passed function. However, the redirection doesn't seem to be working for me. When I visit myapp.com/tcgata i get an error page saying *'invalid function (default/tcgata)'*. Where am I going wrong? Is it a routing issue? a regex issue? I am sure it is something simple I am missing, but I think I need some extra eyes to find it. Furthermore, if there is an easier way to do what I am seeing to achieve, I am all ears! thanks in advance Simon
[web2py] Re: wb2py with existing database
Also one for MySQL: http://code.google.com/p/web2py/source/browse/scripts/extract_mysql_models.py
Re: [web2py] Re: Python Negative Popularity
I think pypy have a few of that - promising LTS - python 2.x is their main branch - includes an implementation of greenlet - numpy is being developed and already part of pypy - Armin Rigo is working on STM latest pypy works with web2py, and integration of pypy+uwsgi is in progress
[web2py] Re: wb2py with existing database
On Thursday, March 29, 2012 1:26:54 PM UTC-4, pbreit wrote: Also one for MySQL: http://code.google.com/p/web2py/source/browse/scripts/extract_mysql_models.py I think the other one is a little more thorough, so may be better even for MySQL.
Re: [web2py] Re: wb2py with existing database
Nice. Actually I think tweaking the one Anthony provided will be easier since this DB is a mongoDB instance, and all fields have the same type (and no relationships to speak of). On Thu, Mar 29, 2012 at 1:26 PM, pbreit pbreitenb...@gmail.com wrote: Also one for MySQL: http://code.google.com/p/web2py/source/browse/scripts/extract_mysql_models.py
[web2py] Re: Using routes.py as a dispatcher for URL shortener app
routes_in = ( (r'^/?$', r'/app_name/default/index'), (r'^/(?Purl[^/]*)/?$', r'/app_name/default/index/\gurl'), ) in your root-level routes.py The drawback is that you will lose access to all other apps (including admin) but that can be a good thing for public deployments. You can catch the other apps by adding route patterns that match them before your catch-all pattern (the patterns are processed in order, and the first match is used). Anyway, using the parametric router and specifying the url-shortening app as the default app might be simpler: routers = dict( BASE = dict( default_application = 'shortener', default_controller = 'default', default_function = 'index', ), ) Then http://myapp.com/tcgata will get routed to http://myapp.com/shortener/default/index/tcgata, and tcgata will be available to the index() function in request.args(0). Anthony
[web2py] Re: Versions earlier than 1.77.1?
I am pretty sure this is not an effect of the upgrade of web2py. This is an error from the database saying it it no able to perform and UPDATE record on the Accounts view because is affects multiple base tables. I cannot say if the problem is the version of the database driver. On Thursday, 29 March 2012 12:25:01 UTC-5, Willoughby wrote: Thanks for the help! Traceback below. Accounts is a view on my SQLServer DB. Looking at it, wonder if it's a difference in PYODBC versions between prod and my desktop. Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 205, in restricted exec ccode in environment File C:/web2py/applications/TheReckoning/controllers/accounts.py http://127.0.0.1:8000/admin/default/edit/TheReckoning/controllers/accounts.py, line 60, in module File C:\web2py\gluon\globals.py, line 173, in lambda self._caller = lambda f: f() File C:/web2py/applications/TheReckoning/controllers/accounts.py http://127.0.0.1:8000/admin/default/edit/TheReckoning/controllers/accounts.py, line 28, in account_detail if form.accepts(request.vars,session) : File C:\web2py\gluon\sqlhtml.py, line 1272, in accepts self.table._db(self.table._id == self.record[self.id_field_name]).update(**fields) File C:\web2py\gluon\dal.py, line 7591, in update return self.db._adapter.update(tablename,self.query,fields) File C:\web2py\gluon\dal.py, line 1116, in update self.execute(sql) File C:\web2py\gluon\dal.py, line 1392, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1386, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: ('42000', [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]View or function 'Accounts' is not updatable because the modification affects multiple base tables. (4405) (SQLExecDirectW)) On Thursday, March 29, 2012 12:30:20 PM UTC-4, Massimo Di Pierro wrote: The earliest I have is 1.80.1. Yet, it should work with the latest. Send me the error you get and I will be happy to take a look. Massimo On Thursday, 29 March 2012 10:46:20 UTC-5, Anthony wrote: Unfortunately the code blows up with current web2py - something about 'updateable' views no longer being allowed. What does updateable views mean? Are you talking about generic views? If so, they can be enabled via the following in a model file: response.generic_patterns = ['*'] Though for security reasons, it's not recommended to be quite so liberal with allowing generic views. See http://web2py.com/books/default/chapter/29/10#Generic-views. If that's not the issue, have you actually tried version 1.77 (or other later versions) -- even if you app doesn't work with 1.99, it might work with some other earlier version. Anyway, perhaps Massimo has older versions available somewhere. Anthony
Re: [web2py] Re: Using routes.py as a dispatcher for URL shortener app
Good point, Anthony. I forgot they are evaluated in order. So you can declare them explicitly before the generic pattern and achieve the same result. For bonus points, OP, you should make it RESTful like I did with mine and then heavily leverage the default layout :) Mine's currently up at the super cliché url http://rdzr.co :) On Thu, Mar 29, 2012 at 1:40 PM, Anthony abasta...@gmail.com wrote: routes_in = ( (r'^/?$', r'/app_name/default/index'), (r'^/(?Purl[^/]*)/?$', r'/app_name/default/index/\gurl'), ) in your root-level routes.py The drawback is that you will lose access to all other apps (including admin) but that can be a good thing for public deployments. You can catch the other apps by adding route patterns that match them before your catch-all pattern (the patterns are processed in order, and the first match is used). Anyway, using the parametric router and specifying the url-shortening app as the default app might be simpler: routers = dict( BASE = dict( default_application = 'shortener', default_controller = 'default', default_function = 'index', ), ) Then http://myapp.com/tcgata will get routed to http://myapp.com/shortener/default/index/tcgata, and tcgata will be available to the index() function in request.args(0). Anthony
[web2py] Re: Versions earlier than 1.77.1?
Okay, thank you for taking a look. It's the same application pointing to the same view in the same DB though, so you can understand my confusion. I'll try Anthony's suggestion of v1.77 - if that fails as well I guess I'll try downgrading some drivers. I'm REALLY not ready to rewrite this thing at this point! On Thursday, March 29, 2012 1:45:01 PM UTC-4, Massimo Di Pierro wrote: I am pretty sure this is not an effect of the upgrade of web2py. This is an error from the database saying it it no able to perform and UPDATE record on the Accounts view because is affects multiple base tables. I cannot say if the problem is the version of the database driver. On Thursday, 29 March 2012 12:25:01 UTC-5, Willoughby wrote: Thanks for the help! Traceback below. Accounts is a view on my SQLServer DB. Looking at it, wonder if it's a difference in PYODBC versions between prod and my desktop. Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 205, in restricted exec ccode in environment File C:/web2py/applications/TheReckoning/controllers/accounts.py http://127.0.0.1:8000/admin/default/edit/TheReckoning/controllers/accounts.py, line 60, in module File C:\web2py\gluon\globals.py, line 173, in lambda self._caller = lambda f: f() File C:/web2py/applications/TheReckoning/controllers/accounts.py http://127.0.0.1:8000/admin/default/edit/TheReckoning/controllers/accounts.py, line 28, in account_detail if form.accepts(request.vars,session) : File C:\web2py\gluon\sqlhtml.py, line 1272, in accepts self.table._db(self.table._id == self.record[self.id_field_name]).update(**fields) File C:\web2py\gluon\dal.py, line 7591, in update return self.db._adapter.update(tablename,self.query,fields) File C:\web2py\gluon\dal.py, line 1116, in update self.execute(sql) File C:\web2py\gluon\dal.py, line 1392, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1386, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: ('42000', [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]View or function 'Accounts' is not updatable because the modification affects multiple base tables. (4405) (SQLExecDirectW)) On Thursday, March 29, 2012 12:30:20 PM UTC-4, Massimo Di Pierro wrote: The earliest I have is 1.80.1. Yet, it should work with the latest. Send me the error you get and I will be happy to take a look. Massimo On Thursday, 29 March 2012 10:46:20 UTC-5, Anthony wrote: Unfortunately the code blows up with current web2py - something about 'updateable' views no longer being allowed. What does updateable views mean? Are you talking about generic views? If so, they can be enabled via the following in a model file: response.generic_patterns = ['*'] Though for security reasons, it's not recommended to be quite so liberal with allowing generic views. See http://web2py.com/books/default/chapter/29/10#Generic-views. If that's not the issue, have you actually tried version 1.77 (or other later versions) -- even if you app doesn't work with 1.99, it might work with some other earlier version. Anyway, perhaps Massimo has older versions available somewhere. Anthony
[web2py] Login username fake ending character
Hi, I need to be able to add a character to the end of a username that can be changed by us. This character is not actually stored in the database for the username however it must be entered for the username to validate. For example: username: 012 - is stored in the database Login with: 012 would fail Login with: 012R would succeed This is a business requirement so even if I don't like this idea I still need to program it. How to make this work with the current login system? Is there a way to capture the form submit before the handler actually processes it, pull the last character if it is valid pass the username without the character to the real login validator? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] how do I use response.render or response.view to return a .csv file, as if using /default/index.csv
Simple example:- I have an index() controller thats sets some variables. I have a view default/index.html that displays the variables. I have another view default/index.csv that renders the variables (e.g. as a,b,c) and this downloads ok as a file (with filename index.csv) if I visit the url ../default/index.csv I added a form to index.html, with a submit button called 'download', in the index controller, if the user has clicked the 'download' button, I am trying to use response.view or response.render to do the equivalent of manually visiting the url that ended in '.csv' Various failed attempts so far, I either get a view on the screen with 'None', or view not found, or currently:- if request.vars.btn == 'download': response.view = 'default/index.csv' return locals() else: return locals() the above causes the index.csv to be displayed in the browser with html,header and body tags (which are not in the view), how do I get this 'view' to be downloaded as a file named 'index.csv' !?
Re: [web2py] how do I use response.render or response.view to return a .csv file, as if using /default/index.csv
add that response.headers['Content-Type']='text/csv'
Re: [web2py] Login username fake ending character
Yes you can capture the form submit. Instead of: def user(): .. return dict(form=auth()) you can do: def user(): .. #TODO validate submitted username .. if request.args(0) == 'login' and request.post_vars.username: .. .. request.post_vars.username = request.vars.username = request.post_vars.username[:-1] # remove last character .. return dict(form=auth()) Note you should do things before calling auth(). Marin On Thu, Mar 29, 2012 at 8:09 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi, I need to be able to add a character to the end of a username that can be changed by us. This character is not actually stored in the database for the username however it must be entered for the username to validate. For example: username: 012 - is stored in the database Login with: 012 would fail Login with: 012R would succeed This is a business requirement so even if I don't like this idea I still need to program it. How to make this work with the current login system? Is there a way to capture the form submit before the handler actually processes it, pull the last character if it is valid pass the username without the character to the real login validator? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Using routes.py as a dispatcher for URL shortener app
This is a neat solution Anthony (actually, it was my original idea for solving this). however I seem to be getting the same error: *invalid function (default/tcgata)*. Forgive me, is this code in the root-level routes.py? or a routes.py in * applications/shortener*? Should anything else be in routes.py? S On Thursday, March 29, 2012 6:40:09 PM UTC+1, Anthony wrote: routes_in = ( (r'^/?$', r'/app_name/default/index'), (r'^/(?Purl[^/]*)/?$', r'/app_name/default/index/\gurl'), ) in your root-level routes.py The drawback is that you will lose access to all other apps (including admin) but that can be a good thing for public deployments. You can catch the other apps by adding route patterns that match them before your catch-all pattern (the patterns are processed in order, and the first match is used). Anyway, using the parametric router and specifying the url-shortening app as the default app might be simpler: routers = dict( BASE = dict( default_application = 'shortener', default_controller = 'default', default_function = 'index', ), ) Then http://myapp.com/tcgata will get routed to http://myapp.com/shortener/default/index/tcgata, and tcgata will be available to the index() function in request.args(0). Anthony
Re: [web2py] Login username fake ending character
Thanks that works exactly how I need it to. On Thu, Mar 29, 2012 at 11:22 AM, Marin Pranjić marin.pran...@gmail.comwrote: Yes you can capture the form submit. Instead of: def user(): .. return dict(form=auth()) you can do: def user(): .. #TODO validate submitted username .. if request.args(0) == 'login' and request.post_vars.username: .. .. request.post_vars.username = request.vars.username = request.post_vars.username[:-1] # remove last character .. return dict(form=auth()) Note you should do things before calling auth(). Marin On Thu, Mar 29, 2012 at 8:09 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi, I need to be able to add a character to the end of a username that can be changed by us. This character is not actually stored in the database for the username however it must be entered for the username to validate. For example: username: 012 - is stored in the database Login with: 012 would fail Login with: 012R would succeed This is a business requirement so even if I don't like this idea I still need to program it. How to make this work with the current login system? Is there a way to capture the form submit before the handler actually processes it, pull the last character if it is valid pass the username without the character to the real login validator? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Smarttable SQLFORM.grid
Will check! Thanks On Wednesday, 28 March 2012 18:59:34 UTC-7, tomt wrote: You may be thinking of 'powertable'. This plugin presents a grid that includes a typeahead search function. It can be found at https://bitbucket.org/rochacbruno/powertable. - Tom On Monday, March 26, 2012 2:24:42 PM UTC-6, greenpoise wrote: What I was looking for was a type-ahead function using SQLFORM.smartgrid instead of typing a word and pressing search. On Thursday, 22 March 2012 16:15:23 UTC-7, Alan Etkin wrote: I think you mean SQLFORM.smartgrid. Book's 7.8 section (the features are explained there): ... A SQLFORM.smartgrid looks a lot like a grid, in fact it contains a grid but it is designed to take as input not a query but only one table and to browse said table and selected referencing tables. ... On Mar 22, 7:16 pm, greenpoise danel.sega...@gmail.com wrote: Are these two equivalents?? I remember using smartables at some point. What I liked about it was the search feature without having to press any button to search for my text within a table. Does SQLFORM.grid provides something similar?? Thanks d
[web2py] Re: Smarttable SQLFORM.grid
Powertable is the one I was working on. I just wish I could somehow implement an 'add record' function to the + button. On Thursday, 29 March 2012 11:55:33 UTC-7, greenpoise wrote: Will check! Thanks On Wednesday, 28 March 2012 18:59:34 UTC-7, tomt wrote: You may be thinking of 'powertable'. This plugin presents a grid that includes a typeahead search function. It can be found at https://bitbucket.org/rochacbruno/powertable . - Tom On Monday, March 26, 2012 2:24:42 PM UTC-6, greenpoise wrote: What I was looking for was a type-ahead function using SQLFORM.smartgrid instead of typing a word and pressing search. On Thursday, 22 March 2012 16:15:23 UTC-7, Alan Etkin wrote: I think you mean SQLFORM.smartgrid. Book's 7.8 section (the features are explained there): ... A SQLFORM.smartgrid looks a lot like a grid, in fact it contains a grid but it is designed to take as input not a query but only one table and to browse said table and selected referencing tables. ... On Mar 22, 7:16 pm, greenpoise danel.sega...@gmail.com wrote: Are these two equivalents?? I remember using smartables at some point. What I liked about it was the search feature without having to press any button to search for my text within a table. Does SQLFORM.grid provides something similar?? Thanks d
Re: [web2py] Re: time field in DAL? when I retrieve it, it gives me as nontype instead of time type.
Wonderful! Thank you! On Thu, Mar 29, 2012 at 9:05 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: default_time = datetime.time(12,00) (row.start_hour or default_time) request.now.time() On Thursday, 29 March 2012 02:50:12 UTC-5, Kenny wrote: I tried to compare by doing {{=row.start_hour request.now.time()}}br/ start_hour is defined as 'time' error : TypeError: can't compare datetime.time to NoneType How can I convert time field to be time type? so I can compare them. Also, one last question is how can I show times in different timezone? Do I need to use pypt? thank you.
[web2py] Re: Login username fake ending character
Maybe something like: def check_username(form): if not form.vars.username.endswith('R') form.errors.username = 'Invalid username' auth.settings.login_onvalidation = [check_username] Anthony On Thursday, March 29, 2012 2:09:44 PM UTC-4, Detectedstealth wrote: Hi, I need to be able to add a character to the end of a username that can be changed by us. This character is not actually stored in the database for the username however it must be entered for the username to validate. For example: username: 012 - is stored in the database Login with: 012 would fail Login with: 012R would succeed This is a business requirement so even if I don't like this idea I still need to program it. How to make this work with the current login system? Is there a way to capture the form submit before the handler actually processes it, pull the last character if it is valid pass the username without the character to the real login validator? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Login username fake ending character
def user(): .. #TODO validate submitted username .. if request.args(0) == 'login' and request.post_vars.username: .. .. request.post_vars.username = request.vars.username = request.post_vars.username[:-1] # remove last character .. return dict(form=auth()) That doesn't check whether the last character is correct, so 012R would succeed, but so would 012X or any character at the end of the username. Anthony
[web2py] Re: Using routes.py as a dispatcher for URL shortener app
This is a neat solution Anthony (actually, it was my original idea for solving this). however I seem to be getting the same error: *invalid function (default/tcgata)*. Forgive me, is this code in the root-level routes.py? or a routes.py in * applications/shortener*? Should anything else be in routes.py? It should be in the root level routes.py, and nothing else is required in that file. Note, whenever you change routes.py, you have to reload routes, either by restarting the server or by clicking the Reload routes button on the home page of the admin app (or by visiting /admin/default/reload_routes). Anthony
Re: [web2py] Login username fake ending character
I just used the following because I don't want their login to succeed if they enter no character IE: 012 the real username without the character should also fail. if request.args(0) == 'login' and request.post_vars.username: login_char = request.post_vars.username[-1] if login_char == 'R': request.post_vars.username = request.vars.username = request.post_vars.username[:-1]# remove last character else: request.post_vars.username = request.vars.username = request.post_vars.username + 'X' On Thu, Mar 29, 2012 at 12:34 PM, Anthony abasta...@gmail.com wrote: def user(): .. #TODO validate submitted username .. if request.args(0) == 'login' and request.post_vars.username: .. .. request.post_vars.username = request.vars.username = request.post_vars.username[:-**1] # remove last character .. return dict(form=auth()) That doesn't check whether the last character is correct, so 012R would succeed, but so would 012X or any character at the end of the username. Anthony -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Python Negative Popularity
I can't agree with you more here, Python 3.0 was a major flop, forcing internationalization down everyone's throats, and screwing up string operations for everyone else. On Thursday, March 29, 2012 9:26:48 AM UTC-7, Massimo Di Pierro wrote: I believe the non-backward compatibility of Python 3.0 and the monopolization of major conferences by Django (which was great 5 years ago but it loses to most of the other frameworks by now) are part of the cause. The other cause I think the raise of multi core processors. Python does not handle them well. The only option is multi-process applications but their are not very easy to write. This is not a problem for web applications. I also think the drop to be significant although not necessarily a long term trend. Python could rebound easily by: - extending the life of 2.x with 2.8 (including as much goodies from 3.x as possible but backward compatibility) and promising LTS - merging stackles and/or gevent - including a standard request/response objects in the libraries - include the request library as replacement for urlib/urlib2 - provide a windows distribution which includes PIL/NumPi/SciPy and is not commercial - stop the Django community from monopolizing every forum (it is still losing to Rails and therefore not the future) and emphasize diversity. - stop the purists who do bash Python projects that are working and popular for not being Pythonic (whatever it means, you do not hear of Java projects not being Javonic). - go back to target schools. I was at PyCon and it is mostly a recruiting place where consultants advertise themselves and their companies. Very few talks are technical. Meanwhile many schools are moving away from Python in favor of JavaScript. This makes no sense to me but perhaps there is something that can be done. Massimo On Thursday, 29 March 2012 08:42:08 UTC-5, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0? http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
Re: [web2py] Login username fake ending character
I just used the following because I don't want their login to succeed if they enter no character IE: 012 the real username without the character should also fail. if request.args(0) == 'login' and request.post_vars.username: login_char = request.post_vars.username[-1] if login_char == 'R': request.post_vars.username = request.vars.username = request.post_vars.username[:-1]# remove last character else: request.post_vars.username = request.vars.username = request.post_vars.username + 'X' Actually, Marin's original solution would already protect against entering the real username without the extra character because it stripped the last character, which would therefore not match the username in the db. The problem was that it would succeed with any extra character at the end, not just with 'R'. Your solution above handles that problem, though I think the onvalidation solution is simpler and more straightforward (and it enables you to emit a custom error message for the particular case where the last character is incorrect if desired). Anthony
Re: [web2py] Login username fake ending character
Yes I think you are correct, your solution is cleaner and explains the problem. However the last character would still need to be removed so your solution would need to be changed to: def check_username(form): if not form.vars.username.endswith('R') form.errors.username = 'Invalid username' else: form.vars.username = forms.vars.username[:-1] auth.settings.login_onvalidation = [check_username] Or is there a different way to handle that? On Thu, Mar 29, 2012 at 1:01 PM, Anthony abasta...@gmail.com wrote: I just used the following because I don't want their login to succeed if they enter no character IE: 012 the real username without the character should also fail. if request.args(0) == 'login' and request.post_vars.username: login_char = request.post_vars.username[-1] if login_char == 'R': request.post_vars.username = request.vars.username = request.post_vars.username[:-**1]# remove last character else: request.post_vars.username = request.vars.username = request.post_vars.username + 'X' Actually, Marin's original solution would already protect against entering the real username without the extra character because it stripped the last character, which would therefore not match the username in the db. The problem was that it would succeed with any extra character at the end, not just with 'R'. Your solution above handles that problem, though I think the onvalidation solution is simpler and more straightforward (and it enables you to emit a custom error message for the particular case where the last character is incorrect if desired). Anthony -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Login username fake ending character
Oops, right. In that case, I would reverse the if/else. On Thursday, March 29, 2012 4:11:13 PM UTC-4, Detectedstealth wrote: Yes I think you are correct, your solution is cleaner and explains the problem. However the last character would still need to be removed so your solution would need to be changed to: def check_username(form): if not form.vars.username.endswith('R') form.errors.username = 'Invalid username' else: form.vars.username = forms.vars.username[:-1] auth.settings.login_onvalidation = [check_username] Or is there a different way to handle that? On Thu, Mar 29, 2012 at 1:01 PM, Anthony abasta...@gmail.com wrote: I just used the following because I don't want their login to succeed if they enter no character IE: 012 the real username without the character should also fail. if request.args(0) == 'login' and request.post_vars.username: login_char = request.post_vars.username[-1] if login_char == 'R': request.post_vars.username = request.vars.username = request.post_vars.username[:-**1]# remove last character else: request.post_vars.username = request.vars.username = request.post_vars.username + 'X' Actually, Marin's original solution would already protect against entering the real username without the extra character because it stripped the last character, which would therefore not match the username in the db. The problem was that it would succeed with any extra character at the end, not just with 'R'. Your solution above handles that problem, though I think the onvalidation solution is simpler and more straightforward (and it enables you to emit a custom error message for the particular case where the last character is incorrect if desired). Anthony -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Login username fake ending character
Is check_username triggered before or after the database validation? I am not able to check it now. Marin On Thu, Mar 29, 2012 at 10:46 PM, Anthony abasta...@gmail.com wrote: Oops, right. In that case, I would reverse the if/else. On Thursday, March 29, 2012 4:11:13 PM UTC-4, Detectedstealth wrote: Yes I think you are correct, your solution is cleaner and explains the problem. However the last character would still need to be removed so your solution would need to be changed to: def check_username(form): if not form.vars.username.en**dswith('R') form.errors.username = '**Invalid username' else: form.vars.username = forms.vars.username[:-1] auth.settings.login_**onvalidation = [check_username**] Or is there a different way to handle that? On Thu, Mar 29, 2012 at 1:01 PM, Anthony abasta...@gmail.com wrote: I just used the following because I don't want their login to succeed if they enter no character IE: 012 the real username without the character should also fail. if request.args(0) == 'login' and request.post_vars.username: login_char = request.post_vars.username[-1] if login_char == 'R': request.post_vars.username = request.vars.username = request.post_vars.username[:-**1**]# remove last character else: request.post_vars.username = request.vars.username = request.post_vars.username + 'X' Actually, Marin's original solution would already protect against entering the real username without the extra character because it stripped the last character, which would therefore not match the username in the db. The problem was that it would succeed with any extra character at the end, not just with 'R'. Your solution above handles that problem, though I think the onvalidation solution is simpler and more straightforward (and it enables you to emit a custom error message for the particular case where the last character is incorrect if desired). Anthony -- -- Regards, Bruce Wade http://ca.linkedin.com/in/**brucelwadehttp://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.**fitnessfriendsfinder.comhttp://www.fitnessfriendsfinder.com
[web2py] Email verification for user registration
Hi Group, I am trying to implement a fairly standard procedure for user registration: after a user submits his/her email address, an email is sent, and by clicking on the link contained in that email, the user is registered. How do we implement this without writing anything to the DB until the user has clicked on the link in the email? This should work even if the user closes the browser and confirms his/her registration a few days later. I have a custom user account/authentication table, so would like to use that for this. Is there any example I can follow? Thanks.
[web2py] Re: Python Negative Popularity
I don't think it's quite a fall just that the pot is bigger and they added JS to the JavaScript so it's rankings boosted a bit. On Thursday, March 29, 2012 6:42:08 AM UTC-7, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0? http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html 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] Login username fake ending character
If i am correct this will not work because it should be: 1. check last character 2. remove last character 3. do db validation I think onvalidation does db validation and then 12. Db validation will not pass because usernames are stored without last character (as stated in first post). Not sure if I am right but should be easy to check :) Marin On Thu, Mar 29, 2012 at 10:55 PM, Marin Pranjić marin.pran...@gmail.comwrote: Is check_username triggered before or after the database validation? I am not able to check it now. Marin On Thu, Mar 29, 2012 at 10:46 PM, Anthony abasta...@gmail.com wrote: Oops, right. In that case, I would reverse the if/else. On Thursday, March 29, 2012 4:11:13 PM UTC-4, Detectedstealth wrote: Yes I think you are correct, your solution is cleaner and explains the problem. However the last character would still need to be removed so your solution would need to be changed to: def check_username(form): if not form.vars.username.en**dswith('R') form.errors.username = '**Invalid username' else: form.vars.username = forms.vars.username[:-1] auth.settings.login_**onvalidation = [check_username**] Or is there a different way to handle that? On Thu, Mar 29, 2012 at 1:01 PM, Anthony abasta...@gmail.com wrote: I just used the following because I don't want their login to succeed if they enter no character IE: 012 the real username without the character should also fail. if request.args(0) == 'login' and request.post_vars.username: login_char = request.post_vars.username[-1] if login_char == 'R': request.post_vars.username = request.vars.username = request.post_vars.username[:-**1**]# remove last character else: request.post_vars.username = request.vars.username = request.post_vars.username + 'X' Actually, Marin's original solution would already protect against entering the real username without the extra character because it stripped the last character, which would therefore not match the username in the db. The problem was that it would succeed with any extra character at the end, not just with 'R'. Your solution above handles that problem, though I think the onvalidation solution is simpler and more straightforward (and it enables you to emit a custom error message for the particular case where the last character is incorrect if desired). Anthony -- -- Regards, Bruce Wade http://ca.linkedin.com/in/**brucelwadehttp://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.**fitnessfriendsfinder.comhttp://www.fitnessfriendsfinder.com
[web2py] Re: Versions earlier than 1.77.1?
That's one thing about web2py is that it's stated backwards compatible throughout the documentation. The error you're having is being thrown by the sql server. If your view is comprised of multiple base tables, your update statement needs to only affect one of those tables at a time. So if there are three tables in your view, you need to have three update statements. On Thursday, March 29, 2012 10:53:46 AM UTC-7, Willoughby wrote: Okay, thank you for taking a look. It's the same application pointing to the same view in the same DB though, so you can understand my confusion. I'll try Anthony's suggestion of v1.77 - if that fails as well I guess I'll try downgrading some drivers. I'm REALLY not ready to rewrite this thing at this point! On Thursday, March 29, 2012 1:45:01 PM UTC-4, Massimo Di Pierro wrote: I am pretty sure this is not an effect of the upgrade of web2py. This is an error from the database saying it it no able to perform and UPDATE record on the Accounts view because is affects multiple base tables. I cannot say if the problem is the version of the database driver. On Thursday, 29 March 2012 12:25:01 UTC-5, Willoughby wrote: Thanks for the help! Traceback below. Accounts is a view on my SQLServer DB. Looking at it, wonder if it's a difference in PYODBC versions between prod and my desktop. Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 205, in restricted exec ccode in environment File C:/web2py/applications/TheReckoning/controllers/accounts.py http://127.0.0.1:8000/admin/default/edit/TheReckoning/controllers/accounts.py, line 60, in module File C:\web2py\gluon\globals.py, line 173, in lambda self._caller = lambda f: f() File C:/web2py/applications/TheReckoning/controllers/accounts.py http://127.0.0.1:8000/admin/default/edit/TheReckoning/controllers/accounts.py, line 28, in account_detail if form.accepts(request.vars,session) : File C:\web2py\gluon\sqlhtml.py, line 1272, in accepts self.table._db(self.table._id == self.record[self.id_field_name]).update(**fields) File C:\web2py\gluon\dal.py, line 7591, in update return self.db._adapter.update(tablename,self.query,fields) File C:\web2py\gluon\dal.py, line 1116, in update self.execute(sql) File C:\web2py\gluon\dal.py, line 1392, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1386, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: ('42000', [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]View or function 'Accounts' is not updatable because the modification affects multiple base tables. (4405) (SQLExecDirectW)) On Thursday, March 29, 2012 12:30:20 PM UTC-4, Massimo Di Pierro wrote: The earliest I have is 1.80.1. Yet, it should work with the latest. Send me the error you get and I will be happy to take a look. Massimo On Thursday, 29 March 2012 10:46:20 UTC-5, Anthony wrote: Unfortunately the code blows up with current web2py - something about 'updateable' views no longer being allowed. What does updateable views mean? Are you talking about generic views? If so, they can be enabled via the following in a model file: response.generic_patterns = ['*'] Though for security reasons, it's not recommended to be quite so liberal with allowing generic views. See http://web2py.com/books/default/chapter/29/10#Generic-views. If that's not the issue, have you actually tried version 1.77 (or other later versions) -- even if you app doesn't work with 1.99, it might work with some other earlier version. Anyway, perhaps Massimo has older versions available somewhere. Anthony
[web2py] Re: Login username fake ending character
class MyStrangeRequirement(object): def __init__(self,s='R',error_message='forgot the R?'): self.s=s self.error_message = error_message def __call__(self,value): if not (value and value.endswith(self.s)): return (value, self.error_message) return value[:-len(self.s)] db.auth_user.username.requires.insert(0, MyStrangeRequirement()) On Thursday, 29 March 2012 13:09:44 UTC-5, Detectedstealth wrote: Hi, I need to be able to add a character to the end of a username that can be changed by us. This character is not actually stored in the database for the username however it must be entered for the username to validate. For example: username: 012 - is stored in the database Login with: 012 would fail Login with: 012R would succeed This is a business requirement so even if I don't like this idea I still need to program it. How to make this work with the current login system? Is there a way to capture the form submit before the handler actually processes it, pull the last character if it is valid pass the username without the character to the real login validator? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Using routes.py as a dispatcher for URL shortener app
Hmm, this is bizarre. I was aware of the reloading routes and it is still not working. I even made a blank 'shortener' scaffold app and added the routes.py from above at root level. http://127.0.0.1/jujuju gives the same errors as above. I'll muck about a bit more and see whats going wrong. I must be missing something daft.
[web2py] Agree on some terms before registration
Dear ALL, How can i make the user agree to some term using a check box before registration ??
[web2py] Re: Smarttable SQLFORM.grid
I get what you are saying. I wrote a function (not on web2py, but it's javascript...) // this will capture the 'enter' key when pressed inside the text box, so searching works better. function IEKeyCap(e) { if (e.keyCode == 13) {dsCustomers.filter(myFilterFunc)}; } function FilterData() { dsCustomers.filter(myFilterFunc); } function StartFilterTimer() { if (StartFilterTimer.timerID) clearTimeout(StartFilterTimer.timerID); StartFilterTimer.timerID = setTimeout(function() { StartFilterTimer.timerID = null; FilterData(); }, 100); } and here was my html that fired it... input class=searchbox onkeyup=StartFilterTimer(); type=text name=srch id=srch This was using the Adobe Spry framework, but it's essentially the same. When you press a key, it starts the timer (for 100ms). If the timer was already going and you press another key, it restarts the timer. After 100ms, it then calls the filter function. If they press enter (keycode 13) it will also call the filter function. I think the problem here is that the SQLFORM.smartgrid isn't AJAX, in that when you click 'search' instead of just reloading the grid with the filtered data, it just redirects you (to the exact same page you're on) and shows you the filtered data. The only way I know to do it with AJAX is to write my own smartgrid, or use Adobe Spry Framework because it's awesome - and you can just tell web2py that you want that dict as a json. On Monday, March 26, 2012 1:24:42 PM UTC-7, greenpoise wrote: What I was looking for was a type-ahead function using SQLFORM.smartgrid instead of typing a word and pressing search. On Thursday, 22 March 2012 16:15:23 UTC-7, Alan Etkin wrote: I think you mean SQLFORM.smartgrid. Book's 7.8 section (the features are explained there): ... A SQLFORM.smartgrid looks a lot like a grid, in fact it contains a grid but it is designed to take as input not a query but only one table and to browse said table and selected referencing tables. ... On Mar 22, 7:16 pm, greenpoise danel.sega...@gmail.com wrote: Are these two equivalents?? I remember using smartables at some point. What I liked about it was the search feature without having to press any button to search for my text within a table. Does SQLFORM.grid provides something similar?? Thanks d
[web2py] How to use web2py auth using JavaScript+ajax?
I need to do a major rework in order to move client-side functionality to the browser and using Javascript to get more responsive client side experience with no refresh etc. That means web2py will give a rich server side functionality and all client work to be performed via JavaScript and Ajax. I made several tests and see this integration working just perfect. I successfully implemented auth with web2py. Now I need to make possible login/logout with just Javascript and Ajax snd calling web2py auth remotely. How to implement it so that I get the same functionality with sessions, etc? Assuming this is working, then how to retain the users' session state? Thanks in advance,
[web2py] Re: Python Negative Popularity
Guido is working for Google. GAE is having Python as a primary language - e.g. all libraries are implemented on Python first, Java and Go next. So we get a priority for Python. So from GAE point of view you better use Python to have an advantage. If not using GAE what alternatives we have? PHP is not secure and is outdated. Google refuses to use it on GAE for security reasons. Javascript is the only possibility for the client side, node.js makes it possible for server side. Java is bloated, inefficient, etc. So basically it boils down to two options: Javascript and Python. On Thursday, March 29, 2012 6:42:08 AM UTC-7, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0? http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html 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
[web2py] Re: Primary Key tables in MSSQL. Cannot get them to work
Yes, I don't think you can use SQLFORM crud unless you have an 'id' column, or another primary key column that is an INT. On Wednesday, March 28, 2012 5:28:44 PM UTC-7, Andrew wrote: Thankyou Derek, I will give it a try , but this was only a simple, cut down, test case to get it to work initially. I originally had a string for the PK, and I also wanted to test multi column PKs. I am confident the 'id' will work, but it doesn't address the other scenarios. My real goal is to change another base adaptor, but I'm using MSSQL as my baseline as it is supposed to work OK. The next thing I will try is to do some db interaction without forms or grids. I think that might be where the issue is. Thanks again. On Thursday, March 29, 2012 10:50:41 AM UTC+13, Derek wrote: Try changing your field1 type to 'id'. like this: Field('Field1', 'id'), On Tuesday, March 27, 2012 10:56:44 PM UTC-7, Andrew wrote: Hello, I posted on this issue some time ago and I'm pretty sure it was working again after a fix from DenesL. However I can't get Primary Key tables in MSSQL to work. They get created OK, but I get errors with a Form in a view. I originally made the Key a string, but then switched to integer just to see if it made a difference. : *Model:* dbSQL = DAL('mssql://) # 1 Column PK dbSQL.define_table('web2py_int_PK', Field('Field1', 'integer'), Field('Field2', 'string', length=20), format='%(Field1)s', primarykey = ['Field1'], migrate=True) *Controller:* def web2py_int_PK_form(): form = SQLFORM(dbSQL.web2py_int_PK) if form.process().accepted: response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill out the form' return dict(form=form) *View:* {{extend 'layout.html'}} h1Primary Key Form Test/h1 {{=form}} I get this in the ticket: File D:\Mercurial\web2py\gluon\dal.py, line 6912, in __getitem__ return dict.__getitem__(self, str(key)) KeyError: '_id' It looks like it is trying to retrieve the value for _id , but looking at the code __init__ for a table, _id never gets set for a table with a Primary Key. (look at lines 6752, 6762, 6772). Just wondering if something like line 772 in sqlhtml.py (In the SQLFORM __init__ method). self.id_field_name = table._id.name could cause the above lookup of the _id key ? Do Forms work with keyed tables ? Thanks Andrew W
[web2py] Re: Tracking/Tracing actions
Are you getting any error messages? What do you mean by this is not yet working. On Thursday, March 29, 2012 8:10:38 AM UTC-7, blackthorne wrote: Hello, I am working on a secure documentation system that should support file uploads but also to give the ability to trace user actions like download/upload of files. This should be integrated in the portal itself so that the administrator doesn't need to parse web log files and trace users and IP's. Example: user Malkovich submitted a file: report.docx with hash: 102310239123123 at 2012.03.27 10:12:45 (GMT) user BigFatCat downloaded the file: report.docx (id: 1201010121) at 2012.03.27 12:11:05 (GMT) ... So, I just said what I have and I want, so now let me tell have I done about this: in the model: ... db.define_table('attachment', Field('name', requires=IS_NOT_EMPTY()), Field('filename'), Field('description'), Field('doc_type', requires=IS_IN_SET(['text','report','image','other']), default='other'), Field('hash', 'string'), Field('file','upload'), format='%(name)s') db.define_table('logs', Field('message','string', requires=IS_NOT_EMPTY()), Field('full_description','text'), Field('action', 'string', requires=IS_IN_SET(['create','remove','download','upload', 'edit','other']),default='download'), Field('attachments', 'list:reference attachment', notnull=False), Field('user', 'list:reference auth_user'), Field('happened_on','datetime', default=datetime.datetime.now())) ... in the controller: def hash(file): return hashlib.md5(open(file).read()).hexdigest() @auth.requires_login() def insert_file(): form = SQLFORM(db.attachment, upload=URL('download'), fields=['name', 'description', 'file']) if request.vars.file!=None: form.vars.filename = request.vars.file.filename # not sure about this one... form.vars.hash = hash(file) if form.process().accepted: db.logs.insert(message='file submitted', full_description=forn.vars.hash, action='upload', attachments='', user= auth.user.id, happened_on=request.now) response.flash = 'form accepted' elif form.errors: response.flash = 'something went wrong, try harder' record = db.attachment(request.args(0)) or redirect(URL('index')) return dict(form=form) ... This is not yet working but don't think I am on the right track? Tips? Thank you
[web2py] Re: help with IS_IN_DB?
What does your view look like? On Wednesday, March 28, 2012 5:41:43 PM UTC-7, drayco wrote: I can try to show in form of input and output a dbset, but i want to modify prices, because it depends of store In model if store.store_id7: armazones = db((db.eyewear.observaciones== '')(db.eyewear.modelo!='SOLAR')) elif store.store_id6: armazones = db((db.eyewear.observaciones!='2DA JORNADA 2010')) else: armazones = db(db.eyewear.id0) interes=0.0 if store.store_id==9: interes=1.25 elif store.store_id9: interes=1.10 if interes0.0: i=0 for armazon in armazones: armazones[i].precio=armazon.precio*interes+(armazon.precio*interes)%10 i=i+1 In definition of table db.define_table(notas, Field(store_id,db.stores, label='Sucursal',comment='Es a la que se encuentra asignado'), Field('nota', 'integer', default=None, writable=False,label='Remisión(Sistema)',comment='Asignado por el sistema'), Field('armazon1',db.eyewear, default=None,requires=IS_NULL_OR(IS_IN_DB(armazones,'eyewear.id','%(marca)s %(modelo)s %(color)s %(caract1)s $%(precio)s'))), Field('modelo1','string', default=None, requires=IS_NULL_OR(IS_ALPHANUMERIC(error_message='¡Deben ser caracteres alfanumericos, sin espacios en blanco ó ñ!')),label='Modelo armazon1'), Field('color1','string', default=None, requires=IS_NULL_OR(IS_ALPHANUMERIC(error_message='¡Deben ser caracteres alfanumericos, sin espacios en blanco ó ñ!')),label='Color(es) armazon1'), Field('obser1','string', default=None, label='Observaciones 1',comment='Para el laboratorio'), Field('lente1',db.lentes, default=None,requires=IS_NULL_OR(IS_IN_DB(glases,'lentes.id','%(tecnoGradua)s %(material)s %(tipo)s %(tecnoVisual)s %(tratamiento)s $%(promo)s'))), Field('soloLoC1','string', default=None,requires=IS_NULL_OR(IS_IN_SET(soloLoC)), label='Lejos ó Cerca 1'), Field('tinte1','string', default=None, requires=IS_NULL_OR(IS_IN_SET(tintes))), Field(total, double, default=0, writable=False), Field(descuento, integer, default=0, requires=IS_INT_IN_RANGE(0,41,error_message='Debe ser Numero positivo entre 0 y 40'), comment='15% maximo permitido'), Field(anticipo, double, default=0, requires=[IS_NOT_EMPTY(error_message='No puede estar vacio'),IS_FLOAT_IN_RANGE(0.0,2.0,error_message='Debe ser un numero positivo entre 0 y 2')],comment='35% minimo para descuento'), Field(pagos, double, default=0, writable=False), Field(saldo, double, default=0, writable=False), ) db.notas.store_id.represent = lambda value: '%(id)s.- %(store)s' % db.stores(value) if value else '' db.notas.armazon1.represent = lambda value: '%(marca)s %(modelo)s %(color)s %(caract1)s $%(promo)s' % db.eyewear(value) if value else '' db.notas.lente1.represent = lambda value: '%(tecnoGradua)s %(material)s %(tipo)s %(tecnoVisual)s %(tratamiento)s $%(promo)s' % db.lentes(value) if value else '' However, only show data of db not of dbset Can you help me? Is it better is_in_set or sqlform.factory?
[web2py] Storing class instances in sessions... or somewhere
I have an existing application that I am trying to get running as AJAX with web2py (locally, but eventually to run on GAE). The application makes use of class instances to store much of the data which would be used for user sessions. I understand that session can't be used to store class instances but for the time being I want to keep the instances for each session (about 200K of data). Sooner or later I guess I will need to save this data in the data store, but at the moment I'm trying to get a prototype up and running and reworking the code to get the data into/out of a database is more pain than I can face atm. The instances are pickleable (well, cPickle doesn't complain) My options seem to be: * cache in ram using the session id as a key and * dumping the instance to a string, saving the string to session (on GAE will this be the same as cache.ram?) Are there other approaches? What's the best way to go about this? Also, in the next update of the documentation, this would be a useful detail to include on the session related sections. Thanks in advance Brendan
[web2py] Re: pop-up verification
Take a look at this: http://web2py.com/books/default/chapter/29/7#FORM Specifically this example: db.define_table('numbers', Field('a', 'integer'), Field('b', 'integer'), Field('c', 'integer', readable=False, writable=False)) def my_form_processing(form): c = form.vars.a * form.vars.b if c 0: form.errors.b = 'a*b cannot be negative' else: form.vars.c = c def insert_numbers(): form = SQLFORM(db.numbers) if form.process(onvalidation=my_form_processing).accepted: session.flash = 'record inserted' redirect(URL()) return dict(form=form) What you want to do is write your own validator, so that it will check if the data is already in the database, and if so, modify the form such that there is an extra checkbox 'i am sure that i know that this is already there'. Perhaps that will help? On Tuesday, March 27, 2012 1:14:02 PM UTC-7, Larry Wapnitsky wrote: Last question of the day, I promise... So, I have data that exists in my database. If a user enters a value that already exists, I want to prompt them with an are you sure? type question before the function that adds/updates the data continues. How do I interrupt my current function to do so without leaving the page and losing data? Thanks, Larry
[web2py] Re: Date field mask or another value
is certainly a valid year. 99 could be a valid calendar month, depending on your calendar. You should probably specify what the valid range of values are. Try the IS_MATCH with a regex. On Tuesday, March 27, 2012 8:05:11 AM UTC-7, Adriano Almeida wrote: Hi, I want a field (may be string,date or number, no prob) to have a format of MM (valid year and month) or if it is left null, to be 99. How Could I accomplished that? I have tried : Field('A0514_DT_FIN','date',notnull=True, label= 'Dt Fim (MM)', default= '99') and then the check: db.tb0514_bihc_consultor_nivel.A0514_DT_FIN.requires = IS_EMPTY_OR(IS_DATE(format=T('%Y%m'), error_message='formato deve ser MM! ou vazio')) It does not work as 99 is not a valid month and is not a valid year. Any ideas?
[web2py] Re: Email verification for user registration
Web2py has some functionality built-in that may work for you. In a model file: auth.settings.registration_requires_verification = True I don't know the exact behavior.
[web2py] Re: Agree on some terms before registration
add a boolean field to the registration page and require it to be true auth.settings.custom_fields['auth_user'].append(Field('agree','boolean',requires=IS_NOT_EMPTY(error_message='you must agree this'))) On Thursday, 29 March 2012 17:15:31 UTC-5, Hassan Alnatour wrote: Dear ALL, How can i make the user agree to some term using a check box before registration ??
Re: [web2py] Tracking/Tracing actions
I need to create a form that submits files and at the same time, stores the user who did it, the name of the file, its hash, the time. Other things like his IP address, his web client would be interesting as well. I see two ways: 1) some sort of method tracing (a decorator maybe) that informs me what calls have been done to some controller 2) include in the uploading form, insertions to the database that also keep track of what has been done (the solution I'm trying) While I want to keep files metadata stored on the database, I want them to be stored on the file system. So how can I create a form that uploads the file and stores all this metadata on the database (including getting the filename, its hash,...)? On Mar 30, 2012, at 12:11 AM, Derek wrote: Are you getting any error messages? What do you mean by this is not yet working. On Thursday, March 29, 2012 8:10:38 AM UTC-7, blackthorne wrote: Hello, I am working on a secure documentation system that should support file uploads but also to give the ability to trace user actions like download/upload of files. This should be integrated in the portal itself so that the administrator doesn't need to parse web log files and trace users and IP's. Example: user Malkovich submitted a file: report.docx with hash: 102310239123123 at 2012.03.27 10:12:45 (GMT) user BigFatCat downloaded the file: report.docx (id: 1201010121) at 2012.03.27 12:11:05 (GMT) ... So, I just said what I have and I want, so now let me tell have I done about this: in the model: ... db.define_table('attachment', Field('name', requires=IS_NOT_EMPTY()), Field('filename'), Field('description'), Field('doc_type', requires=IS_IN_SET(['text','report','image','other']), default='other'), Field('hash', 'string'), Field('file','upload'), format='%(name)s') db.define_table('logs', Field('message','string', requires=IS_NOT_EMPTY()), Field('full_description','text'), Field('action', 'string', requires=IS_IN_SET(['create','remove','download','upload', 'edit','other']),default='download'), Field('attachments', 'list:reference attachment', notnull=False), Field('user', 'list:reference auth_user'), Field('happened_on','datetime', default=datetime.datetime.now())) ... in the controller: def hash(file): return hashlib.md5(open(file).read()).hexdigest() @auth.requires_login() def insert_file(): form = SQLFORM(db.attachment, upload=URL('download'), fields=['name', 'description', 'file']) if request.vars.file!=None: form.vars.filename = request.vars.file.filename # not sure about this one... form.vars.hash = hash(file) if form.process().accepted: db.logs.insert(message='file submitted', full_description=forn.vars.hash, action='upload', attachments='', user=auth.user.id, happened_on=request.now) response.flash = 'form accepted' elif form.errors: response.flash = 'something went wrong, try harder' record = db.attachment(request.args(0)) or redirect(URL('index')) return dict(form=form) ... This is not yet working but don't think I am on the right track? Tips? Thank you signature.asc Description: Message signed with OpenPGP using GPGMail