Re: [web2py] Re: REF: Upload of Files
Anthony, I have noticed an error in the code. I have created a very simple form to test the upload without using components. The code is as follows: Controller: = def index(): form = SQLFORM.factory(Field(first_name),Field(quotes_file, upload, uploadfolder=os.path.join(request.folder, 'uploads'))) test = '' first_name = '' if request.vars.first_name: first_name = My test if request.vars.quotes_file: test = My File return locals() View: == {{extend 'layout.html'}}br File: {{=test}}br First name: {{=first_name}} {{=form}} {{=BEAUTIFY(request.vars)}} When i submit the form with a file attached the beautify displays the file content and the value for first_name. But, the value for test = My File is not being displayed in the view, while the first_name = My test is being displayed without any problem. I have further noticed this error in the page source after making a submit: script type=text/javascript!-- // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = Are you sure you want to delete this object?;var w2p_ajax_date_format = %Y-%m-%d;var w2p_ajax_datetime_format = %Y-%m-%d %H:%M:%S;var ajax_error_500 = 'An error occured, please a href=/testapp/default/index?first_name=bggfbfgamp;quotes_file=FieldStorage%28%27quotes_file%27%2C+%27rows+%282%29.csv%27%2C+%27circular.circular_no%2Ccircular.recipients%2Ccircular.circular_title%2Ccircular.circular_date%5Cr%5CnNAZ%2F1%2F2013%2CALL+MEMBERS+OF+STAFF%2CLunch+to+be+served+at+the+Motel%2C2013-03-01%5Cr%5Cn%27%29reload/a the page' //--/script any idea on whats going on here? On Wed, Mar 20, 2013 at 9:01 PM, Teddy Nyambe software@gmail.comwrote: Actually this this is how am loading it, please advise: {{=A('Quotes', component=URL('quotes','quotes.loadp ), target='quote-content')}} div id='quote-content'/div One funny thing is when I add a simple text field to the SQLFORM.factory and submit sample content...its displayed...only for upload is not showing. On Mar 20, 2013 4:23 PM, Anthony abasta...@gmail.com wrote: Did you set ajax=True or ajax_trap=True in your LOAD() call? If not, the form will get posted to the action of the containing page, not the component action. Anthony On Wednesday, March 20, 2013 10:06:28 AM UTC-4, software.ted wrote: Anthony, Am having a very funny behavior. I am loading a form in a component quotes.load in another page of a div. When i access the component directly through the URL address the {{=BEAUTIFY(request.vars)}} am able to see the uploaded file, but accessing it through the component its sending empty quotes upload file note the code: controller def quotes(): form = SQLFORM.factory(Field(first_**name), Field(quotes, upload, uploadfolder=os.path.join(**request.folder,'uploads'))) file_name= first_name = if request.vars.quotes: file_name=test if request.vars.first_name: first_name = Testing return dict(form=form, file_name = file_name, first_name = first_name) view:: First name is: {{=file_name}}br {{=form}}br First name is:{{=first_name}} filename is returning empty all the time. On Wed, Mar 20, 2013 at 3:21 PM, Anthony abas...@gmail.com wrote: As is, your code should generate an error because you haven't specified an upload folder, which is required when passing new Field objects to SQLFORM.factory. Try: import os SQLFORM.factory(Field(quotes**, upload, uploadfolder=os.path. join(requ**est.folder, 'uploads'))) If you don't want to save the file at all, though, then don't call form.process(). Instead, just check for the uploaded file: if request.vars.quotes: manage_quotes(request.vars.quo**tes.file) Anthony On Wednesday, March 20, 2013 8:30:29 AM UTC-4, software.ted wrote: I want to upload a file to web2py and then manipulate it. I dont want to save it into the database...after manipulating it i want to delete it. How do i do that. I have been trying like this but all fails: Controller: def quotes(): form = SQLFORM.factory(Field(quotes, upload) if form.process().accepted: manage_quotes(form.vars.**quotes**) elif form.errors: response.flash = form has error After upload I cannot see the uploaded in the upload folder! regards -- .... ... Teddy Lubasi Nyambe Opensource Zambia Lusaka, ZAMBIA Cell: +260 97 7760473 website: http://www.opensource.org.zm ~/ Human Knowledge belongs to the world! - AntiTrust Man is a tool-using animal. Without tools he is nothing, with tools he is all - Thomas Carlyle 1795-1881 /~ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving
[web2py] auth.settings.logout_onlogout = lambda user: on_logout(auth,session)
After upgrading to web2py version 2.4.4 this no longer works: auth.settings.logout_onlogout = lambda user: on_logout(auth,session) I get the following error: global name 'on_logout' is not defined. on_logout(auth,session) is a function in a module which clears all the settings of the cms part of my application. Is there another way to call on_logout(auth,session) in web2py 2.4.4? Kind regards, Annet -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] MySQL Error
I have this action that verify is a group exist, if not, it create this group: verify_install = db(db.auth_group.role == 'admin').select() if not verify_install: auth.add_group('admin', 'Administrative Group') redirect https://ec2-23-22-64-190.compute-1.amazonaws.com/examples/global/vars/redirect(URL https://ec2-23-22-64-190.compute-1.amazonaws.com/examples/global/vars/URL('install', 'index')) works well in sqlite, but in mysql I am getting this error: IntegrityError: (1452, u'Cannot add or update a child row: a foreign key constraint fails (`chipincode`.`auth_event`, CONSTRAINT `auth_event_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE)') -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Mongodb error in appadmin
The action I have a table/collection with 3 objects In the table this is reverenced as Field('host_id', mdb.hoststable, comment=Like nim or hmc server., label=T('Destination Host ID')), But when in appadmin I select a other object to change then it throws a error. The error Ticket ID 127.0.0.1.2013-03-21.15-46-39.9f2786b5-d69c-4e31-a6c9-dd76f3692e59 type 'exceptions.RuntimeError' uncaught exception when updating rows: MongoDB can only handle up to 8-byte ints Version web2py^(TM) Version 2.4.5-stable+timestamp.2013.03.18.22.46.22 Python Python 2.7.3: /usr/bin/python2.7 (prefix: /usr) Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. Traceback (most recent call last): File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py, line 410, in module File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py, line 277, in update File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/sqlhtml.py, line 1527, in accepts self.id_field_name]).update(**fields) File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py, line 9834, in update ret = db._adapter.update(tablename,self.query,fields) File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py, line 5450, in update raise RuntimeError(uncaught exception when updating rows: %s % e) RuntimeError: uncaught exception when updating rows: MongoDB can only handle up to 8-byte ints -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Send email with link to SQLFORM.grid edit form
there's a logic step that you are missing the grid is - usually - protected with signed urls, if you want to access the edit form of the grid itself. First of all, you should embed in the mail the signed url, otherwise a not authorized is expected. but, since the signature depends on the specific user accessing the site, you can't know in advance what will be his session key. You'd better prepare a bounce link to send by email, and redirect from there to the signed link to access the record (cause when the user access the bounce page, you know how to generate his specific signature) On Thursday, March 21, 2013 3:51:21 AM UTC+1, Jim S wrote: I want to automatically generate an email whenever a record is added to a specific table and embed in that email a link to edit the record using SQFORM.grid. I have it working, sending the email and all, but when the user clicks on the link to view the record they get a 'not authorized' message. This happens even if the user is logging into a fresh session when clicking on the link. Here is the code I'm using: msg = ('htmlhead/headbodyA new support ticket was added. Click a href=http://127.0.0.1:8000/ibc/support/index/edit/support_tickets/%s;here/a to view./body/html' % (id)) mail.send('em...@domain.com','New IBC Lead added',msg) Any ideas? -Jim -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: bootstrap's modal and web2py's LOAD
On 03/20/2013 08:33 AM, Martín Miranda wrote: Here ... http://linuxapuntes.blogspot.com.ar/2013/03/plugin-modal-bootstrap-web2py.html Hi Marti'n, Richard, Thank for your time. Actually I think I solved it in another way allowing: 1) Load modal by an ajax call 2) use template system for modal html generation I reached this goal like this. Add this small piece of javascript: $(document).ready(function() { // Support for AJAX loaded modal window. // Focuses on first input textbox after it loads the window. $('[data-toggle=modal]').click(function(e) { e.preventDefault(); var url = $(this).attr('href'); if (url.indexOf('#') == 0) { $(url).modal('open'); } else { $.get(url, function(data) { var rnd=Math.floor(Math.random()*1); //Do this in two steps or scripts in data will be loaded too early $('body').append($('div /', {'id':'modal'+rnd})); $('#modal'+rnd).append(data); var modal_element = $('body #modal'+rnd).children()[0]; $(modal_element).modal(); $(modal_element).on('hidden', function(e){ $(this).parent().remove(); }); }).success(function() { $('input:text:visible:first').focus(); }); } }); }); This looks for elements with data-toggle=modal such that when an element like this is found into a view: !-- Button to trigger modal -- a href={{=URL(f='add_traceback', args=[request.args(0), bug.tstamp])}} role=button class=btn btn-primary data-toggle=modalAdd bug/a The href is called via Ajax, so the controller (add_traceback in this case) defined as: def add_traceback(): form = SQLFORM.factory( Field('message'), formstyle='bootstrap', buttons=[], _action = URL('add_traceback')) if form.process().accepted: response.message='form submitted' return dict(form=form) Is just a normal controller function with no modifications, buttons=[] and formstyle have been added to allow a better rendering of the form but they are not necessary. Finally the view related to add_traceback is: div id=modalwindow class=modal hide fade tabindex=-1 role=dialog aria-labelledby=myModalLabel aria-hidden=true div class=modal-header button type=button class=close data-dismiss=modal aria-hidden=true×/button h3 id=myModalLabelAdd bug to database/h3 /div div class=modal-body {{=form}} /div div class=modal-footer button class=btn data-dismiss=modal aria-hidden=trueClose/button button class=btn btn-primarySave changes/button /div /div script type=text/javascript $('#modalwindow form').on('submit', function(e){ e.preventDefault(); var frm = $('#modalwindow form'); $.ajax({ type: frm.attr('method'), url: frm.attr('action'), data: frm.serialize(), success: function (data) { $('#modalwindow').modal('hide'); } }); }); $('#modalwindow .btn-primary').click(function(e){ $('#modalwindow form').submit(); }); /script The javascript in the view ensures that the modal form is submitted as ajax as well instead of a post. I'll try to make a plugin and publish/document all this soon. -- Vincenzo Ampolo http://goshawknest.wordpress.com/ http://vincenzo-ampolo.net/ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Mongodb error in appadmin
Created the following table mdb.define_table('syscommands', Field('commandname', type='string', unique=True, label=T('Commandname')), Field('commandline', type='string', label=T('Command')), Field('host_id', mdb.hoststable, comment=Like nim or hmc server., label=T('Destination Host ID')), Field('description', type='string', label=T('Description')), Field('fase','string', comment=Fase 1 is storage, Fase 2 is Profile Creation, Fase 3 is VIO deployment, Fase 4 is Lpar deployment.., label=T('Fase')), 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), format='%(commandname)s', migrate=settings.migrate) # Table rules for command mdb.syscommands.fase.requires = IS_IN_SET(['1', '2', '3', '4']) #mdb.syscommands.host_id.requires = IS_NOT_EMPTY() mdb.syscommands.commandname.requires = IS_NOT_EMPTY() mdb.syscommands.host_id.requires = IS_IN_DB(mdb, 'hoststable.id', 'hoststable.hostname') mdb.syscommands.commandline.requires = IS_NOT_EMPTY() it revers to this table mdb.define_table('hoststable', Field('hostname', type='string', unique=True, label=T('Hostname')), Field('description', type='string', label=T('Description')), Field('netboot', type='string', label=T('Netboot information')), Field('ip', type='string', default='192.168.1.x', label=T('IP Address')), Field('connectcmd', type='string', default='ssh', label=T('Connection command')), Field('useraccount', type='string', default='root', label=T('Default User')), 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), format='%(hostname)s', migrate=settings.migrate) # Table Hosts rules mdb.hoststable.hostname.requires = IS_NOT_EMPTY() mdb.hoststable.ip.requires = IS_NOT_EMPTY() Then when I create a record in appadmin and after that change this item It throws this error. Ticket ID 127.0.0.1.2013-03-21.17-03-38.3cfba30b-5706-4bdb-af50-faa6be3ed179 type 'exceptions.RuntimeError' uncaught exception when updating rows: MongoDB can only handle up to 8-byte ints Version web2py^(TM) Version 2.4.5-stable+timestamp.2013.03.18.22.46.22 Python Python 2.7.3: /usr/bin/python2.7 (prefix: /usr) Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. Traceback (most recent call last): File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py, line 410, in module File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py, line 277, in update File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/sqlhtml.py, line 1527, in accepts self.id_field_name]).update(**fields) File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py, line 9834, in update ret = db._adapter.update(tablename,self.query,fields) File /home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py, line 5450, in update raise RuntimeError(uncaught exception when updating rows: %s % e) RuntimeError: uncaught exception when updating rows: MongoDB can only handle up to 8-byte ints -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Mongodb error in appadmin
seems to me that a lot of people are interested in using mongodb but really few are contributing back with tests and patches. BTW: you DO know that Mongo generally doesn't play well with joins, right ? Using references in mongodb is not a smart design. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Mongodb error in appadmin
Op 21-03-13 17:50, Niphlod schreef: seems to me that a lot of people are interested in using mongodb but really few are contributing back with tests and patches. BTW: you DO know that Mongo generally doesn't play well with joins, right ? Using references in mongodb is not a smart design. Mongodb as far as I know does not have joins :) But it did accept it, so I decided to post the error. But this is mysql database design that I did put over 1 on 1 I have to redo the database design to be nicer to Mongo (I am just looking up to the conversion, even though I now have both databases so its just a matter of writing a copy and past program after I created the new database structure in mongo) . I would love to have some pointers about how though define mongo in db.py in a proper nosql way. Thanks for the remark btw :) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Backup Restore problems
I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone (https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: package import
Thanks for the advice! I checked all the folders and removed some example and doc folders that didn't include code. All the other folders contain inits. Still not working. I wonder if it is intended that way? Can you just put packages in modules that make global imports? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py and timezones
hum... I use this and solves pretty much the bulk of the DLST issues that were problematic for me. http://pytz.sourceforge.net (its the Olsen TZ DB wrapped in python) I found it a little tricky at first, but once i got my head wrapped around the different permutations of dates (past, presents, different time zones, DLST, DT formats) i work with, things cleared up pretty quickly. Anyways, works for me. - Mart On Sunday, March 17, 2013 7:31:24 PM UTC-7, Massimo Di Pierro wrote: I was looking at code to detect the user timezone and store dates consistently in UTC format. I made some changes in trunk to handle this. I could use some help testing. 1) In the header of your layout.html add: {{if not session.timezone:}} script jQuery(function(){jQuery.post('{{=URL('default','set_timezone')}}',{timezone:(new Date()).getTimezoneOffset()});}); /script {{pass}} 2) in the default controller: def set_timezone(): session.timezone = int(request.vars.timezone)/60 3) Use the new timezone attribute of validators in trunk: Field('birthday','datetime',requires = IS_DATETIME(timezone=session.timezone) Does it work for you? Suggestions for improvement? Massimo -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Why does appadmin execute conditional models?
If I put a code inside models/controller_name/something.py, it gets executed when running appadmin. Tested in 2.2.1 and trunk. Marin -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Why does appadmin execute conditional models?
uhm. I'm not familiar with the implementation, but appadmin needs to be a global management solution What if in your conditional model you defined a table and you want to manage that table from appadmin ? On Thursday, March 21, 2013 11:40:09 AM UTC+1, Marin Pranjić wrote: If I put a code inside models/controller_name/something.py, it gets executed when running appadmin. Tested in 2.2.1 and trunk. Marin -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Error Working With mysql
Dear ALL , i am having some problems starting my project in mysql , it was working fine in sqlite but its not creating any tables in mysql , here is the error : Ticket ID 127.0.0.1.2013-03-21.11-35-49.b053e9f1-2194-47ee-b635-b00b1c370b0c class 'gluon.contrib.pymysql.err.ProgrammingError' (1146, uTable 'wkaleh_db.news' doesn't exist) Version web2py™ (1, 99, 4, datetime.datetime(2011, 12, 14, 14, 46, 14), 'stable') Python Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 204, in restricted exec ccode in environment File C:/web2py/applications/alwkaleh/controllers/default.pyhttp://127.0.0.1:8000/admin/edit/alwkaleh/controllers/default.py , line 888, in module File C:\web2py\gluon\globals.py, line 172, in lambda self._caller = lambda f: f() File C:/web2py/applications/alwkaleh/controllers/default.pyhttp://127.0.0.1:8000/admin/edit/alwkaleh/controllers/default.py , line 634, in index interview=db(db.News.EnglishTitle!= ).select (db.Interview.ALL,orderby=~ db.Interview.id)[:1] File C:\web2py\gluon\dal.py, line 6333, in select return self.db._adapter.select(self.query,fields,attributes) File C:\web2py\gluon\dal.py, line 1282, in select rows = response(sql) File C:\web2py\gluon\dal.py, line 1272, in response self.execute(sql) File C:\web2py\gluon\dal.py, line 1359, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1353, in log_execute ret = self.cursor.execute(*a, **b) File C:\web2py\gluon\contrib\pymysql\cursors.py, line 108, in execute self.errorhandler(self, exc, value) File C:\web2py\gluon\contrib\pymysql\connections.py, line 184, indefaulterrorhandler raise errorclass, errorvalue ProgrammingError: (1146, uTable 'wkaleh_db.news' doesn't exist) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] How to embed Google player in a web2py generated web page to play files retrieved from the database.
I am new to web2py, and I am trying to get an embedded mp3 player to play audio files stored in a database locally. I am using Google player, and I got the following to work on my webpage developed in web2py: embed type=application/x-shockwave-flash src=http://www.google.com/reader/ui/3523697345-audio-player.swf; quality=best flashvars=audioUrl=http://www.pacdv.com/sounds/free-music/glow-in-the-dark.mp3; However, when I tried to substitute embedded python code to play a file retrieved from the database, it will not work: embed type=application/x-shockwave-flash src=http://www.google.com/reader/ui/3523697345-audio-player.swf; quality=best flashvars=audioUrl={{=URL('download', args=image.file)}} I am wondering what it is I am doing wrong as I do not get any sort of error message. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Embed MP3 audio player in HTML via web2py
I am new to using web2py, and I was wondering how to embed an MP3 player into a webpage using web2py. I have made a page with the embedded player, with the MP3 file in a SQL Lite DB, but I cannot get the file to play with the embedded player. I am not sure if this is relevant, but I have jpg and mp3 files in the same database. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] auth.has_permission(...) slow -- any way to speed this up?
I have a table that represents a group, which has permissions on a row-by-row basis. User belongs to certain number of groups, and the rows into the table are kept for convenience sake. I would like to screen that list of rows for a specific permission and exclude those rows from the list. The code looks like this: for row in rows: if not auth.has_permission('update', db.my_table, row): rows.remove(row) Problem is, the auth.has_permission is slow ... on the order of 1.5 seconds when scanning a half-dozen row entries. my_table has around 150K rows. How do I speed this up? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Mongodb error in appadmin
I would love to have some pointers about how though define mongo in db.py in a proper nosql way. Could you open an issue at the project page? If you can, please provide: - The relevant part of the model - A possible set of data which would reproduce the error - Your mongodb driver, database server, web2py and Python versions The MongoDB DAL adapter does some automatic type mapping for id fields. I belive the issue could be realted to that. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Rocket server on two ports
I'm struggling to understand the interfaces syntax. Because I'm using this as a Windows service, I need to set up the options.py file. I see from the documentation ie python web2py.py --help that the ip option is ignored if interfaces is present. What about port (logically that should be ignored as well). To get a minimal config working I've gone with port = 8010 and tried interfaces=0.0.0.0:8020 (my attempt to follow the documentation) or interfaces=[('0.0.0.0',8020)] (based on the example in the options.py file) But I don't get a server at 8020, only at 8010. On Thursday, 21 March 2013 00:05:00 UTC+11, Tim Richardson wrote: The rocket documentation seems to say that the server can be invoked listening on multiple ports. I'm using it as http and I'd like to deploy rocket as ssl (self signed). Then I need to change book marks; running on http and ssl means I can gradually transition. Is this going to blow up? Also, in practice can I just run two web2py instances on two different ports? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Backup Restore problems
Quite right, restoring from, let's say, native mysql dump to postgresql would most certainly not work. That's exactly why web2py uses csv as the export format. I don't think exporting / importing to csv is really recommended over using the native export / import functionality of your database engine or a specialized backup software (depending on your needs). But it works and it quickly covers the most broad spectrum possible. For anything more specific or complex, it's up to the developer to use something else. I don't think web2py should try to reinvent the wheel here. If export to csv failed in your case, what exactly was the problem? The referenced thread is from 2011 and seems to be case specific... Are you saying you have the same exact error? Regards, Ales On Thursday, March 21, 2013 11:12:57 AM UTC+1, dederocks wrote: I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone ( https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE ). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Rocket server on two ports
on command-line should be, in your case web2py.py -i 0.0.0.0:80,0.0.0.0:443:keyfile.key:certfile.cer using the options file, interfaces = [('0.0.0.0', 80), ('0.0.0.0', 443, keyfile.key, certfile.cer)] On Thursday, March 21, 2013 1:29:45 PM UTC+1, Tim Richardson wrote: I'm struggling to understand the interfaces syntax. Because I'm using this as a Windows service, I need to set up the options.py file. I see from the documentation ie python web2py.py --help that the ip option is ignored if interfaces is present. What about port (logically that should be ignored as well). To get a minimal config working I've gone with port = 8010 and tried interfaces=0.0.0.0:8020 (my attempt to follow the documentation) or interfaces=[('0.0.0.0',8020)] (based on the example in the options.py file) But I don't get a server at 8020, only at 8010. On Thursday, 21 March 2013 00:05:00 UTC+11, Tim Richardson wrote: The rocket documentation seems to say that the server can be invoked listening on multiple ports. I'm using it as http and I'd like to deploy rocket as ssl (self signed). Then I need to change book marks; running on http and ssl means I can gradually transition. Is this going to blow up? Also, in practice can I just run two web2py instances on two different ports? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.has_permission(...) slow -- any way to speed this up?
So, basically you're doing get me 150K rows, put them in a list for each of them, query the db for permission if query doesn't return True, scan the 150K list and remove this instance Cycling 150K and removing from a list while checking surely will get your app killed. Firing one query for each row is what seems the problem on the half-dozen set. Try the 'accessible-query' way rows = db(auth.accessible_query('read', db.my_table, auth.user_id)).select(db.my_table.ALL) This will do all the required joins under the hood and resolve in one-query only. On Thursday, March 21, 2013 12:59:57 PM UTC+1, weheh wrote: I have a table that represents a group, which has permissions on a row-by-row basis. User belongs to certain number of groups, and the rows into the table are kept for convenience sake. I would like to screen that list of rows for a specific permission and exclude those rows from the list. The code looks like this: for row in rows: if not auth.has_permission('update', db.my_table, row): rows.remove(row) Problem is, the auth.has_permission is slow ... on the order of 1.5 seconds when scanning a half-dozen row entries. my_table has around 150K rows. How do I speed this up? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Backup Restore problems
Indeed, or quite close: https://code.google.com/p/web2py/issues/detail?id=1387. And to be accurate, I think the issue has more to do with restore than backup. To build on your comment, there are indeed two ways to deal with backup / restore: 1- managed by the database manager using native backup / restore; 2- managed by the user, to send the db to another colleague, or restore an older version through the application. That's what I'm dealing with right now, and it fails on me. Le jeudi 21 mars 2013 13:49:24 UTC+1, LightDot a écrit : Quite right, restoring from, let's say, native mysql dump to postgresql would most certainly not work. That's exactly why web2py uses csv as the export format. I don't think exporting / importing to csv is really recommended over using the native export / import functionality of your database engine or a specialized backup software (depending on your needs). But it works and it quickly covers the most broad spectrum possible. For anything more specific or complex, it's up to the developer to use something else. I don't think web2py should try to reinvent the wheel here. If export to csv failed in your case, what exactly was the problem? The referenced thread is from 2011 and seems to be case specific... Are you saying you have the same exact error? Regards, Ales On Thursday, March 21, 2013 11:12:57 AM UTC+1, dederocks wrote: I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone ( https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE ). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Ref: Problem with simple file upload
This is a repost cause it did not receive much feedback. I have noticed an error in the code below. The book emphasises on upload file storage in the db, but what about simple upload and manipulation. I have created a very simple form to test the upload without using components. The code is as follows: Controller: = def index(): form = SQLFORM.factory(Field(first_ name),Field(quotes_file, upload, uploadfolder=os.path.join(request.folder, 'uploads'))) test = '' first_name = '' if request.vars.first_name: first_name = My test if request.vars.quotes_file: test = My File return locals() View: == {{extend 'layout.html'}}br File: {{=test}}br First name: {{=first_name}} {{=form}} {{=BEAUTIFY(request.vars)}} When i submit the form with a file attached the beautify displays the file content and the value for first_name. But, the value for test = My File is not being displayed in the view, while the first_name = My test is being displayed without any problem. I have further noticed this error in the page source after making a submit: script type=text/javascript!--// These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = Are you sure you want to delete this object?; var w2p_ajax_date_format = %Y-%m-%d; var w2p_ajax_datetime_format = %Y-%m-%d %H:%M:%S; var ajax_error_500 = 'An error occured, please a href=/testapp/default/index? first_name=bggfbfgamp;quotes_ file=FieldStorage%28%27quotes_ file%27%2C+%27rows+%282%29. csv%27%2C+%27circular. circular_no%2Ccircular. recipients%2Ccircular. circular_title%2Ccircular. circular_date%5Cr%5CnNAZ%2F1% 2F2013%2CALL+MEMBERS+OF+STAFF% 2CLunch+to+be+served+at+the+ Motel%2C2013-03-01%5Cr%5Cn%27% 29reload/a the page' //--/script any idea on whats going on here? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Backup Restore problems
I solved a similar case by writing a function to a) use native postgres dump and archive the database and b) present the file to the user for download in the administrative back-end. This function is triggered by cron in my case, but it could also be executed on demand. For this I would use the scheduler and throw in some additional checks so the user doesn't trigger the backup too often. Hope this helps a bit. Regards, Ales On Thursday, March 21, 2013 2:42:51 PM UTC+1, dederocks wrote: Indeed, or quite close: https://code.google.com/p/web2py/issues/detail?id=1387. And to be accurate, I think the issue has more to do with restore than backup. To build on your comment, there are indeed two ways to deal with backup / restore: 1- managed by the database manager using native backup / restore; 2- managed by the user, to send the db to another colleague, or restore an older version through the application. That's what I'm dealing with right now, and it fails on me. Le jeudi 21 mars 2013 13:49:24 UTC+1, LightDot a écrit : Quite right, restoring from, let's say, native mysql dump to postgresql would most certainly not work. That's exactly why web2py uses csv as the export format. I don't think exporting / importing to csv is really recommended over using the native export / import functionality of your database engine or a specialized backup software (depending on your needs). But it works and it quickly covers the most broad spectrum possible. For anything more specific or complex, it's up to the developer to use something else. I don't think web2py should try to reinvent the wheel here. If export to csv failed in your case, what exactly was the problem? The referenced thread is from 2011 and seems to be case specific... Are you saying you have the same exact error? Regards, Ales On Thursday, March 21, 2013 11:12:57 AM UTC+1, dederocks wrote: I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone ( https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE ). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.has_permission(...) slow -- any way to speed this up?
Not exactly. The fields in rows are indices into db.my_table. len(rows) is a small variable number, say around 8. But there it is, anyway. Thank you Mr. Niphlod. Good work! bad_rows = db((db.my_table.id.belongs(rows)) (auth.accessible_query('update', db.my_table, user_id))).select(db.my_table.id) Speed comparison: 1.4 seconds before change, 0.7 seconds after change. 2X. Not bad, although I'd prefer 10X :-) On Thursday, March 21, 2013 9:19:34 PM UTC+8, Niphlod wrote: So, basically you're doing get me 150K rows, put them in a list for each of them, query the db for permission if query doesn't return True, scan the 150K list and remove this instance Cycling 150K and removing from a list while checking surely will get your app killed. Firing one query for each row is what seems the problem on the half-dozen set. Try the 'accessible-query' way rows = db(auth.accessible_query('read', db.my_table, auth.user_id)).select(db.my_table.ALL) This will do all the required joins under the hood and resolve in one-query only. On Thursday, March 21, 2013 12:59:57 PM UTC+1, weheh wrote: I have a table that represents a group, which has permissions on a row-by-row basis. User belongs to certain number of groups, and the rows into the table are kept for convenience sake. I would like to screen that list of rows for a specific permission and exclude those rows from the list. The code looks like this: for row in rows: if not auth.has_permission('update', db.my_table, row): rows.remove(row) Problem is, the auth.has_permission is slow ... on the order of 1.5 seconds when scanning a half-dozen row entries. my_table has around 150K rows. How do I speed this up? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: How to create a loop to add multiple child records
i'll take a look and send it too you the file on the discussion that i've refer above. On Wednesday, March 20, 2013 9:36:49 PM UTC+7, Alex Glaros wrote: thanks for the attached full example Steve did you write it just to assist for this topic? When I go to the app page I get: invalid view (default/register_new.html) do I need to import anything? I will study it and try and get small pieces of it going a bit at a time so that I can understand how it works regarding did you take a look the discussion link above?, I did but I'm not experienced enough to get over my lack of understanding much appreciated! Alex On Wednesday, March 20, 2013 1:05:21 AM UTC-7, 黄祥 wrote: did you take a look the discussion link above? please find attached file that on discussion link above hope this can help * [image: 黄祥] スティファン クリスティ (黄祥) Stifan Kristi (Kou Shou) ジャカルタ、 インドネシア Jakarta, Indonesia 携帯。 +六二 八一八 七八三 一一八 Cell. +62 818 783 118 ウェブサイト : http://stevevanchristie.net Website : http://stevevanchristie.net * On Wed, Mar 20, 2013 at 12:02 PM, Alex Glaros alexg...@gmail.com wrote: is there any way to use python to create the loop? * {{while user keeps adding records:}} {{pass parent ID to variable}} P{{run factory to create child record and auto-insert parentID}}/P {{response.write('do you want to add more child records?')}} {{pass}}* On Tuesday, March 19, 2013 3:21:39 PM UTC-7, Alex Glaros wrote: @Derek: I'm a newbie. Where do I put the Ajax code...in controller, or view..? Does it need some kind of script/script or brackets surrounding it? Can you please type the syntax for linking to a page where user can add addresses? I don't know the best format for linking to functions. For purposes of showing me, assume that the function is called add_partners that I want to link to. Would it just be a href= http://127.0.0.1:8000/**CEA/default/add_partners/http://127.0.0.1:8000/CEA/default/add_partners/ add partner/a ? thanks, Alex On Monday, March 18, 2013 5:33:41 PM UTC-7, Alex Glaros wrote: Does anyone know how to create a loop allowing variable number of child records to be added to a parent? Here’s a sample where only one child is created. The “client” is the parent record and “address” is the child record. http://web2py.com/books/**default/chapter/29/07http://web2py.com/books/default/chapter/29/07 Can anyone please type the code to show how to allow user to add variable number of child records? If it’s easier to do not using factory, that’s fine. Thanks, Alex Glaros One form for multiple tables model: db.define_table('client', Field('name')) db.define_table('address', Field('client','reference client', writable=False,readable=False)**, Field('street'),Field('city')) controller: def register(): form=SQLFORM.factory(db.**client,db.address) if form.process().accepted: id = db.client.insert(**db.client._**filter_fields(form.vars)) form.vars.client=id id = db.address.insert(**db.**address._filter_fields(form.** vars)) response.flash='Thanks for filling the form' return dict(form=form) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Backup Restore problems
Thanks Ales, Basically, you're confirming the native backup / restore choice. I'm concerned though that web2py's csv solution is not reliable, and should therefore be used with high caution -- not to say a word about how slow it is. It feels sad for me that web2py which other than that an incredible tool keeps this unpractical feature. Regards, Andre Le jeudi 21 mars 2013 15:09:23 UTC+1, LightDot a écrit : I solved a similar case by writing a function to a) use native postgres dump and archive the database and b) present the file to the user for download in the administrative back-end. This function is triggered by cron in my case, but it could also be executed on demand. For this I would use the scheduler and throw in some additional checks so the user doesn't trigger the backup too often. Hope this helps a bit. Regards, Ales On Thursday, March 21, 2013 2:42:51 PM UTC+1, dederocks wrote: Indeed, or quite close: https://code.google.com/p/web2py/issues/detail?id=1387. And to be accurate, I think the issue has more to do with restore than backup. To build on your comment, there are indeed two ways to deal with backup / restore: 1- managed by the database manager using native backup / restore; 2- managed by the user, to send the db to another colleague, or restore an older version through the application. That's what I'm dealing with right now, and it fails on me. Le jeudi 21 mars 2013 13:49:24 UTC+1, LightDot a écrit : Quite right, restoring from, let's say, native mysql dump to postgresql would most certainly not work. That's exactly why web2py uses csv as the export format. I don't think exporting / importing to csv is really recommended over using the native export / import functionality of your database engine or a specialized backup software (depending on your needs). But it works and it quickly covers the most broad spectrum possible. For anything more specific or complex, it's up to the developer to use something else. I don't think web2py should try to reinvent the wheel here. If export to csv failed in your case, what exactly was the problem? The referenced thread is from 2011 and seems to be case specific... Are you saying you have the same exact error? Regards, Ales On Thursday, March 21, 2013 11:12:57 AM UTC+1, dederocks wrote: I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone ( https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE ). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Backup Restore problems
so you'd prefer to have it removed alltogether ? On Thursday, March 21, 2013 3:37:44 PM UTC+1, dederocks wrote: Thanks Ales, Basically, you're confirming the native backup / restore choice. I'm concerned though that web2py's csv solution is not reliable, and should therefore be used with high caution -- not to say a word about how slow it is. It feels sad for me that web2py which other than that an incredible tool keeps this unpractical feature. Regards, Andre Le jeudi 21 mars 2013 15:09:23 UTC+1, LightDot a écrit : I solved a similar case by writing a function to a) use native postgres dump and archive the database and b) present the file to the user for download in the administrative back-end. This function is triggered by cron in my case, but it could also be executed on demand. For this I would use the scheduler and throw in some additional checks so the user doesn't trigger the backup too often. Hope this helps a bit. Regards, Ales On Thursday, March 21, 2013 2:42:51 PM UTC+1, dederocks wrote: Indeed, or quite close: https://code.google.com/p/web2py/issues/detail?id=1387. And to be accurate, I think the issue has more to do with restore than backup. To build on your comment, there are indeed two ways to deal with backup / restore: 1- managed by the database manager using native backup / restore; 2- managed by the user, to send the db to another colleague, or restore an older version through the application. That's what I'm dealing with right now, and it fails on me. Le jeudi 21 mars 2013 13:49:24 UTC+1, LightDot a écrit : Quite right, restoring from, let's say, native mysql dump to postgresql would most certainly not work. That's exactly why web2py uses csv as the export format. I don't think exporting / importing to csv is really recommended over using the native export / import functionality of your database engine or a specialized backup software (depending on your needs). But it works and it quickly covers the most broad spectrum possible. For anything more specific or complex, it's up to the developer to use something else. I don't think web2py should try to reinvent the wheel here. If export to csv failed in your case, what exactly was the problem? The referenced thread is from 2011 and seems to be case specific... Are you saying you have the same exact error? Regards, Ales On Thursday, March 21, 2013 11:12:57 AM UTC+1, dederocks wrote: I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone ( https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE ). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Backup Restore problems
Yes - unless someone finds a good use for these two functions. It looks to me that if a record has been removed in a db (e.g. id is not continuous: 1, 2, 4, 5 for example), the restore won't work if the table is linked to another table. This is I think a sufficiently likely case to remove the functions - or am I wrong? Le jeudi 21 mars 2013 15:42:51 UTC+1, Niphlod a écrit : so you'd prefer to have it removed alltogether ? On Thursday, March 21, 2013 3:37:44 PM UTC+1, dederocks wrote: Thanks Ales, Basically, you're confirming the native backup / restore choice. I'm concerned though that web2py's csv solution is not reliable, and should therefore be used with high caution -- not to say a word about how slow it is. It feels sad for me that web2py which other than that an incredible tool keeps this unpractical feature. Regards, Andre Le jeudi 21 mars 2013 15:09:23 UTC+1, LightDot a écrit : I solved a similar case by writing a function to a) use native postgres dump and archive the database and b) present the file to the user for download in the administrative back-end. This function is triggered by cron in my case, but it could also be executed on demand. For this I would use the scheduler and throw in some additional checks so the user doesn't trigger the backup too often. Hope this helps a bit. Regards, Ales On Thursday, March 21, 2013 2:42:51 PM UTC+1, dederocks wrote: Indeed, or quite close: https://code.google.com/p/web2py/issues/detail?id=1387. And to be accurate, I think the issue has more to do with restore than backup. To build on your comment, there are indeed two ways to deal with backup / restore: 1- managed by the database manager using native backup / restore; 2- managed by the user, to send the db to another colleague, or restore an older version through the application. That's what I'm dealing with right now, and it fails on me. Le jeudi 21 mars 2013 13:49:24 UTC+1, LightDot a écrit : Quite right, restoring from, let's say, native mysql dump to postgresql would most certainly not work. That's exactly why web2py uses csv as the export format. I don't think exporting / importing to csv is really recommended over using the native export / import functionality of your database engine or a specialized backup software (depending on your needs). But it works and it quickly covers the most broad spectrum possible. For anything more specific or complex, it's up to the developer to use something else. I don't think web2py should try to reinvent the wheel here. If export to csv failed in your case, what exactly was the problem? The referenced thread is from 2011 and seems to be case specific... Are you saying you have the same exact error? Regards, Ales On Thursday, March 21, 2013 11:12:57 AM UTC+1, dederocks wrote: I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone ( https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE ). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] web2py 2.4.5 is OUT
I know they are not on travis.ci but they exist and can be extended to include user applications. On Tuesday, 19 March 2013 18:07:35 UTC-5, Niphlod wrote: if you're referring to gluon/tests/test_web.py they aren't (at least in travis-ci). you're required to have a running webserver in an outside process when launching test_web On Tuesday, March 19, 2013 11:34:35 PM UTC+1, Massimo Di Pierro wrote: I do not believe the exec thing is any obstacle to testing. applications can be tested in the same way. Current tests incude for example functional testing for the registration and login process in welcome. On Tuesday, 19 March 2013 13:20:41 UTC-5, Richard wrote: I thougth that testing web2py was complexe because of the way the environnement was setup (execute)... So, how is travis-ci is working testing web2py and what the limitation of the test case for instance? Maybe the issue with testing is more for app then web2py it self? Thanks Richard On Tue, Mar 19, 2013 at 2:13 PM, Cliff Kachinske cjk...@gmail.comwrote: I saw a talk on Travis-ci last week. I think it's a great idea. You could also use it to test your own Web2py-based project and do your system regression test using Selenium. On Tuesday, March 19, 2013 11:31:06 AM UTC-4, Niphlod wrote: precisely. for 5-6 years old, it assures to run a set of commands in a fresh environment and logs the results. Given that we have some tests, and that those tests can be invoked, and that we **should** check if web2py works with python 2.5, 2.6, 2.7 it very useful. Additionally the travis environment ships with some services by default, and we're currently using postgresql and mysql to see if the DAL checks out, in addition to sqlite that has always been the embedded option. You all know that t-sql may differ, so we can check if any new feature committed to trunk is fine in nearly-real-time (can watch the status on the github page (https://github.com/web2py/**web2pyhttps://github.com/web2py/web2py, see the green badge) or at https://travis-ci.org/web2py/**web2pyhttps://travis-ci.org/web2py/web2py, if you click on the badge). tl;dr: travis-ci is saving developers from installing 3 python envs and 2 db engines to check if everything runs normally. PS: goes with the announcement that if tests cover what you need and what you use in your app, there will not be a new web2py release without those test pass completely (cause lazy developers can't hide anymore behind the on my system it checked out correctly). The nice addition, on the user-side, is that if you need some feature to be watched closely by the web2py team, you can submit patches or additions to the current tests suite: they'll get integrated in the mainline suite and travis will do the checks automatically. On Tuesday, March 19, 2013 4:06:51 PM UTC+1, Richard wrote: http://en.wikipedia.org/wiki/**Travis_CIhttp://en.wikipedia.org/wiki/Travis_CI I don't that much, but I would say that it is a motor to execute unit tests so it make integration test finally. And I guess once you configure your project to work with it each you commit something on github it will execute all your unit tests and let you know that your build is good to go as long as your unit tests are up to date... Richard On Tue, Mar 19, 2013 at 10:51 AM, Marco Túlio Cícero de M. Porto mtcp...@gmail.com wrote: Hi! forgive my ignorance what's Travis and what does it do ? (explanation for 3 year old if you can) Also, what benefits I can have by integrating it with Web2py ? Thanks for the info. Cheers, Marco Tulio 2013/3/18 Massimo Di Pierro massimo@gmail.com Passes all tests using travis.ci including python 2.5/2.6/2.7 sqlite/mysql/postgres. Thanks to Marc who originally pushed for travis.ci integration one year ago and Niphlod for his help in getting this to work, explaining it to me like a three years old (and I needed the explanation), and for fixing all tests! https://travis-ci.org/web2py/**web2pyhttps://travis-ci.org/web2py/web2py Massimo -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- []'s Marco Tulio -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from
[web2py] Re: installing web2py service on Windows, passing account credentials doesn't work
I believe there is problem in parsing options. Those options are not web2py options. They are winservice options. Please pen a ticket about this. On Wednesday, 20 March 2013 09:36:18 UTC-5, wprins wrote: Hi, I'm trying to set up web2py with alternate account credentials via the command line as per the command line help page, but when I pass the specified options web2py claims there's no such option: C:\web2pypython web2py.py -W help web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2013 Version 2.4.5-stable+timestamp.2013.03.18.22.46.22 Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL( pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP( imaplib) Unknown command - 'help' Usage: 'web2py.py [options] install|update|remove|start [...]|stop|restart [...] |debug [...]' Options for 'install' and 'update' commands only: --username domain\username : The Username the service is to run under --password password : The password for the username --startup [manual|auto|disabled] : How the service starts, default =manual --interactive : Allow the service to interact with the desktop. --perfmonini file: .ini file to use for registering performance monitor data --perfmondll file: .dll file to use when querying the service for performance data, default = perfmondata.dll Options for 'start' and 'stop' commands only: --wait seconds: Wait for the service to actually start or stop. If you specify --wait with the 'stop' option, the service and all dependent services will be stopped, each waiting the specified period. C:\web2pypython web2py.py -W install --username=web2py Usage: python web2py.py web2py.py: error: no such option: --username C:\web2pypython web2py.py -W install --username web2py Usage: python web2py.py web2py.py: error: no such option: --username C:\web2py What am I missing? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] How can I run multiple applications with multiple domains on nginx?
It's not specific to web2py, but may help you maybe : http://stackoverflow.com/questions/11773544/nginx-different-domains-on-same-ip The idea is to create a other server in nginx... Richard On Mon, Mar 18, 2013 at 4:21 PM, Tito Garrido titogarr...@gmail.com wrote: Hi Folks, I am reading the book section: http://web2py.com/books/default/chapter/29/13#Nginx But I couldn't figure out how could I setup nginx to serve multiple domains pointing to a different application on the same web2py instance. Do you have any example? like: mydomain1 - /home/www-data/web2py/applications/myapp1 mydomain2 - /home/www-data/web2py/applications/myapp2 Thanks, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How to embed Google player in a web2py generated web page to play files retrieved from the database.
Probably the problem is the nested quotes in flashvars=audioUrl={{=URL('download', args=image.file)}} should be flashvars=audioUrl={{=URL('download', args=image.file)}} On Thursday, 21 March 2013 00:25:53 UTC-5, Gennaro Kukonu wrote: I am new to web2py, and I am trying to get an embedded mp3 player to play audio files stored in a database locally. I am using Google player, and I got the following to work on my webpage developed in web2py: embed type=application/x-shockwave-flash src=http://www.google.com/reader/ui/3523697345-audio-player.swf; quality=best flashvars=audioUrl=http://www.pacdv.com/sounds/free-music/glow-in-the-dark.mp3; However, when I tried to substitute embedded python code to play a file retrieved from the database, it will not work: embed type=application/x-shockwave-flash src=http://www.google.com/reader/ui/3523697345-audio-player.swf; quality=best flashvars=audioUrl={{=URL('download', args=image.file)}} I am wondering what it is I am doing wrong as I do not get any sort of error message. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Error Working With mysql
What is wkaleh_db? Is is defined somewhere in your code? On Thursday, 21 March 2013 03:38:35 UTC-5, mqa...@gardeniatelco.com wrote: Dear ALL , i am having some problems starting my project in mysql , it was working fine in sqlite but its not creating any tables in mysql , here is the error : Ticket ID 127.0.0.1.2013-03-21.11-35-49.b053e9f1-2194-47ee-b635-b00b1c370b0c class 'gluon.contrib.pymysql.err.ProgrammingError' (1146, uTable 'wkaleh_db.news' doesn't exist) Version web2py™ (1, 99, 4, datetime.datetime(2011, 12, 14, 14, 46, 14), 'stable') Python Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 204, in restricted exec ccode in environment File C:/web2py/applications/alwkaleh/controllers/default.pyhttp://127.0.0.1:8000/admin/edit/alwkaleh/controllers/default.py , line 888, in module File C:\web2py\gluon\globals.py, line 172, in lambda self._caller = lambda f: f() File C:/web2py/applications/alwkaleh/controllers/default.pyhttp://127.0.0.1:8000/admin/edit/alwkaleh/controllers/default.py , line 634, in index interview=db(db.News.EnglishTitle!= ).select (db.Interview.ALL,orderby =~db.Interview.id)[:1] File C:\web2py\gluon\dal.py, line 6333, in select return self.db._adapter.select(self.query,fields,attributes) File C:\web2py\gluon\dal.py, line 1282, in select rows = response(sql) File C:\web2py\gluon\dal.py, line 1272, in response self.execute(sql) File C:\web2py\gluon\dal.py, line 1359, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1353, in log_execute ret = self.cursor.execute(*a, **b) File C:\web2py\gluon\contrib\pymysql\cursors.py, line 108, in execute self.errorhandler(self, exc, value) File C:\web2py\gluon\contrib\pymysql\connections.py, line 184, indefaulterrorhandler raise errorclass, errorvalue ProgrammingError: (1146, uTable 'wkaleh_db.news' doesn't exist) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: package import
This was fixed in 2.4.5. What version of web2py are you using? On Wednesday, 13 March 2013 09:47:38 UTC-5, Phillipp Schmidt wrote: I want to use the tablib package. https://github.com/kennethreitz/tablib So I put it in the modules folder of my application and use `import tablib`. Although the package is working locally, when trying to use it in web2py I keep getting import errors from files inside the package. It doesn't seem to support any global imports from inside the module!? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py and timezones
I have a major patch from Niphlod that replace my naive implementation with one based on pytz. I agree this is the way to go. We have two open issues: 1) should be include pytz in web2py r make it a depencency 2) should we do the pytz import in web2py or should we pass pytz objects to validators (the pytz would be defined outside of web2py), tus giving the option of not using pytz. On Thursday, 21 March 2013 05:28:09 UTC-5, mart wrote: hum... I use this and solves pretty much the bulk of the DLST issues that were problematic for me. http://pytz.sourceforge.net (its the Olsen TZ DB wrapped in python) I found it a little tricky at first, but once i got my head wrapped around the different permutations of dates (past, presents, different time zones, DLST, DT formats) i work with, things cleared up pretty quickly. Anyways, works for me. - Mart On Sunday, March 17, 2013 7:31:24 PM UTC-7, Massimo Di Pierro wrote: I was looking at code to detect the user timezone and store dates consistently in UTC format. I made some changes in trunk to handle this. I could use some help testing. 1) In the header of your layout.html add: {{if not session.timezone:}} script jQuery(function(){jQuery.post('{{=URL('default','set_timezone')}}',{timezone:(new Date()).getTimezoneOffset()});}); /script {{pass}} 2) in the default controller: def set_timezone(): session.timezone = int(request.vars.timezone)/60 3) Use the new timezone attribute of validators in trunk: Field('birthday','datetime',requires = IS_DATETIME(timezone=session.timezone) Does it work for you? Suggestions for improvement? Massimo -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Ref: Problem with simple file upload
I think the problem my be this: {{=BEAUTIFY(request.vars)}}. What if you remove it? On Thursday, 21 March 2013 08:56:44 UTC-5, software.ted wrote: This is a repost cause it did not receive much feedback. I have noticed an error in the code below. The book emphasises on upload file storage in the db, but what about simple upload and manipulation. I have created a very simple form to test the upload without using components. The code is as follows: Controller: = def index(): form = SQLFORM.factory(Field(first_ name),Field(quotes_file, upload, uploadfolder=os.path.join(request.folder, 'uploads'))) test = '' first_name = '' if request.vars.first_name: first_name = My test if request.vars.quotes_file: test = My File return locals() View: == {{extend 'layout.html'}}br File: {{=test}}br First name: {{=first_name}} {{=form}} {{=BEAUTIFY(request.vars)}} When i submit the form with a file attached the beautify displays the file content and the value for first_name. But, the value for test = My File is not being displayed in the view, while the first_name = My test is being displayed without any problem. I have further noticed this error in the page source after making a submit: script type=text/javascript!--// These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = Are you sure you want to delete this object?; var w2p_ajax_date_format = %Y-%m-%d; var w2p_ajax_datetime_format = %Y-%m-%d %H:%M:%S; var ajax_error_500 = 'An error occured, please a href=/testapp/default/index? first_name=bggfbfgamp;quotes_ file=FieldStorage%28%27quotes_ file%27%2C+%27rows+%282%29. csv%27%2C+%27circular. circular_no%2Ccircular. recipients%2Ccircular. circular_title%2Ccircular. circular_date%5Cr%5CnNAZ%2F1% 2F2013%2CALL+MEMBERS+OF+STAFF% 2CLunch+to+be+served+at+the+ Motel%2C2013-03-01%5Cr%5Cn%27% 29reload/a the page' //--/script any idea on whats going on here? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: package import
I just updated to this version, but I am still getting the error. Fany interface, though! Do you know any working packages that I could try to see whether it has something to do with my setup? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Backup Restore problems
Removing the functionality altogether seems extreme. However, perhaps we should change the documentation to remove the backup/restore terminology (i.e., we can describe it as a way to export and import an entire db, but not recommend it as a primary backup strategy and instead recommend native db functionality for that purpose). Anthony On Thursday, March 21, 2013 10:57:05 AM UTC-4, dederocks wrote: Yes - unless someone finds a good use for these two functions. It looks to me that if a record has been removed in a db (e.g. id is not continuous: 1, 2, 4, 5 for example), the restore won't work if the table is linked to another table. This is I think a sufficiently likely case to remove the functions - or am I wrong? Le jeudi 21 mars 2013 15:42:51 UTC+1, Niphlod a écrit : so you'd prefer to have it removed alltogether ? On Thursday, March 21, 2013 3:37:44 PM UTC+1, dederocks wrote: Thanks Ales, Basically, you're confirming the native backup / restore choice. I'm concerned though that web2py's csv solution is not reliable, and should therefore be used with high caution -- not to say a word about how slow it is. It feels sad for me that web2py which other than that an incredible tool keeps this unpractical feature. Regards, Andre Le jeudi 21 mars 2013 15:09:23 UTC+1, LightDot a écrit : I solved a similar case by writing a function to a) use native postgres dump and archive the database and b) present the file to the user for download in the administrative back-end. This function is triggered by cron in my case, but it could also be executed on demand. For this I would use the scheduler and throw in some additional checks so the user doesn't trigger the backup too often. Hope this helps a bit. Regards, Ales On Thursday, March 21, 2013 2:42:51 PM UTC+1, dederocks wrote: Indeed, or quite close: https://code.google.com/p/web2py/issues/detail?id=1387. And to be accurate, I think the issue has more to do with restore than backup. To build on your comment, there are indeed two ways to deal with backup / restore: 1- managed by the database manager using native backup / restore; 2- managed by the user, to send the db to another colleague, or restore an older version through the application. That's what I'm dealing with right now, and it fails on me. Le jeudi 21 mars 2013 13:49:24 UTC+1, LightDot a écrit : Quite right, restoring from, let's say, native mysql dump to postgresql would most certainly not work. That's exactly why web2py uses csv as the export format. I don't think exporting / importing to csv is really recommended over using the native export / import functionality of your database engine or a specialized backup software (depending on your needs). But it works and it quickly covers the most broad spectrum possible. For anything more specific or complex, it's up to the developer to use something else. I don't think web2py should try to reinvent the wheel here. If export to csv failed in your case, what exactly was the problem? The referenced thread is from 2011 and seems to be case specific... Are you saying you have the same exact error? Regards, Ales On Thursday, March 21, 2013 11:12:57 AM UTC+1, dederocks wrote: I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone ( https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE ). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit
[web2py] Re: Backup Restore problems
my point exactly it's a matter on how it's perceived as a one-solution-for-all-exporting-problem vs a rapid way to load fixtures/etc in your environment. On Thursday, March 21, 2013 4:41:48 PM UTC+1, Anthony wrote: Removing the functionality altogether seems extreme. However, perhaps we should change the documentation to remove the backup/restore terminology (i.e., we can describe it as a way to export and import an entire db, but not recommend it as a primary backup strategy and instead recommend native db functionality for that purpose). Anthony On Thursday, March 21, 2013 10:57:05 AM UTC-4, dederocks wrote: Yes - unless someone finds a good use for these two functions. It looks to me that if a record has been removed in a db (e.g. id is not continuous: 1, 2, 4, 5 for example), the restore won't work if the table is linked to another table. This is I think a sufficiently likely case to remove the functions - or am I wrong? Le jeudi 21 mars 2013 15:42:51 UTC+1, Niphlod a écrit : so you'd prefer to have it removed alltogether ? On Thursday, March 21, 2013 3:37:44 PM UTC+1, dederocks wrote: Thanks Ales, Basically, you're confirming the native backup / restore choice. I'm concerned though that web2py's csv solution is not reliable, and should therefore be used with high caution -- not to say a word about how slow it is. It feels sad for me that web2py which other than that an incredible tool keeps this unpractical feature. Regards, Andre Le jeudi 21 mars 2013 15:09:23 UTC+1, LightDot a écrit : I solved a similar case by writing a function to a) use native postgres dump and archive the database and b) present the file to the user for download in the administrative back-end. This function is triggered by cron in my case, but it could also be executed on demand. For this I would use the scheduler and throw in some additional checks so the user doesn't trigger the backup too often. Hope this helps a bit. Regards, Ales On Thursday, March 21, 2013 2:42:51 PM UTC+1, dederocks wrote: Indeed, or quite close: https://code.google.com/p/web2py/issues/detail?id=1387. And to be accurate, I think the issue has more to do with restore than backup. To build on your comment, there are indeed two ways to deal with backup / restore: 1- managed by the database manager using native backup / restore; 2- managed by the user, to send the db to another colleague, or restore an older version through the application. That's what I'm dealing with right now, and it fails on me. Le jeudi 21 mars 2013 13:49:24 UTC+1, LightDot a écrit : Quite right, restoring from, let's say, native mysql dump to postgresql would most certainly not work. That's exactly why web2py uses csv as the export format. I don't think exporting / importing to csv is really recommended over using the native export / import functionality of your database engine or a specialized backup software (depending on your needs). But it works and it quickly covers the most broad spectrum possible. For anything more specific or complex, it's up to the developer to use something else. I don't think web2py should try to reinvent the wheel here. If export to csv failed in your case, what exactly was the problem? The referenced thread is from 2011 and seems to be case specific... Are you saying you have the same exact error? Regards, Ales On Thursday, March 21, 2013 11:12:57 AM UTC+1, dederocks wrote: I'm concerned with the lack of reliability and speed of the recommended backup / restore functions: db.export_to_csv_file and db.import_from_csv_file. They failed in my case, and apparently I'm not alone ( https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/reOzXobYNgE ). Would it be wise to replace the backup function with something like: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'.dump ',targetfile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_dump -f',targetfile, dbname))) elif 'mysql' in db._uri: os.system(' '.join(('mysqldump -r',targetfile, dbname))) and similarly the restore function would be: import os if 'sqlite' in db._uri: os.system(' '.join(('sqlite3',db.path,'',sourcefile))) elif 'postgres' in db._uri: os.system(' '.join(('pg_restore -d',dbname, sourcefile))) elif 'mysql' in db._uri: os.system(' '.join(('mysqlimport',dbname, sourcefile))) Unfortunately I'm not knowlegable enough (yet) about all the various databases supported nor about platform-dependent intricacies, but would this not be a more reliable approach? The only major downside is that restoring a db from x (say sqlite) into y (say postgresql) might not be possible, or require some significant edit of the dump file. And to make the restore smoother, you'd have to figure out the source format -- is this possible? -- --- You received this message because
Re: [web2py] web2py 2.4.5 is OUT
see the other thread on web2py-developers for further details. On Thursday, March 21, 2013 4:19:22 PM UTC+1, Massimo Di Pierro wrote: I know they are not on travis.ci but they exist and can be extended to include user applications. On Tuesday, 19 March 2013 18:07:35 UTC-5, Niphlod wrote: if you're referring to gluon/tests/test_web.py they aren't (at least in travis-ci). you're required to have a running webserver in an outside process when launching test_web On Tuesday, March 19, 2013 11:34:35 PM UTC+1, Massimo Di Pierro wrote: I do not believe the exec thing is any obstacle to testing. applications can be tested in the same way. Current tests incude for example functional testing for the registration and login process in welcome. On Tuesday, 19 March 2013 13:20:41 UTC-5, Richard wrote: I thougth that testing web2py was complexe because of the way the environnement was setup (execute)... So, how is travis-ci is working testing web2py and what the limitation of the test case for instance? Maybe the issue with testing is more for app then web2py it self? Thanks Richard On Tue, Mar 19, 2013 at 2:13 PM, Cliff Kachinske cjk...@gmail.comwrote: I saw a talk on Travis-ci last week. I think it's a great idea. You could also use it to test your own Web2py-based project and do your system regression test using Selenium. On Tuesday, March 19, 2013 11:31:06 AM UTC-4, Niphlod wrote: precisely. for 5-6 years old, it assures to run a set of commands in a fresh environment and logs the results. Given that we have some tests, and that those tests can be invoked, and that we **should** check if web2py works with python 2.5, 2.6, 2.7 it very useful. Additionally the travis environment ships with some services by default, and we're currently using postgresql and mysql to see if the DAL checks out, in addition to sqlite that has always been the embedded option. You all know that t-sql may differ, so we can check if any new feature committed to trunk is fine in nearly-real-time (can watch the status on the github page (https://github.com/web2py/**web2pyhttps://github.com/web2py/web2py, see the green badge) or at https://travis-ci.org/web2py/**web2pyhttps://travis-ci.org/web2py/web2py, if you click on the badge). tl;dr: travis-ci is saving developers from installing 3 python envs and 2 db engines to check if everything runs normally. PS: goes with the announcement that if tests cover what you need and what you use in your app, there will not be a new web2py release without those test pass completely (cause lazy developers can't hide anymore behind the on my system it checked out correctly). The nice addition, on the user-side, is that if you need some feature to be watched closely by the web2py team, you can submit patches or additions to the current tests suite: they'll get integrated in the mainline suite and travis will do the checks automatically. On Tuesday, March 19, 2013 4:06:51 PM UTC+1, Richard wrote: http://en.wikipedia.org/wiki/**Travis_CIhttp://en.wikipedia.org/wiki/Travis_CI I don't that much, but I would say that it is a motor to execute unit tests so it make integration test finally. And I guess once you configure your project to work with it each you commit something on github it will execute all your unit tests and let you know that your build is good to go as long as your unit tests are up to date... Richard On Tue, Mar 19, 2013 at 10:51 AM, Marco Túlio Cícero de M. Porto mtcp...@gmail.com wrote: Hi! forgive my ignorance what's Travis and what does it do ? (explanation for 3 year old if you can) Also, what benefits I can have by integrating it with Web2py ? Thanks for the info. Cheers, Marco Tulio 2013/3/18 Massimo Di Pierro massimo@gmail.com Passes all tests using travis.ci including python 2.5/2.6/2.7 sqlite/mysql/postgres. Thanks to Marc who originally pushed for travis.ci integration one year ago and Niphlod for his help in getting this to work, explaining it to me like a three years old (and I needed the explanation), and for fixing all tests! https://travis-ci.org/web2py/**web2pyhttps://travis-ci.org/web2py/web2py Massimo -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- []'s Marco Tulio -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out .
[web2py] Re: Why does appadmin execute conditional models?
That's intentional. The idea is that appadmin needs access to all the models in order to be able to manage the whole database. If you don't want that for some reason, I think you should be able to change the name of appadmin.py and appadmin.html to something else (the model execution code specifically checks for a controller named appadmin). Anthony On Thursday, March 21, 2013 6:40:09 AM UTC-4, Marin Pranjić wrote: If I put a code inside models/controller_name/something.py, it gets executed when running appadmin. Tested in 2.2.1 and trunk. Marin -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Why does appadmin execute conditional models?
Sure, I can do that. Good idea :-) Thanks. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How can I run multiple applications with multiple domains on nginx?
Yes you can. From the point of nginx treat all domains as one. the use web2py routes.py to map different domains to different apps. On Monday, 18 March 2013 15:21:25 UTC-5, Tito Garrido wrote: Hi Folks, I am reading the book section: http://web2py.com/books/default/chapter/29/13#Nginx But I couldn't figure out how could I setup nginx to serve multiple domains pointing to a different application on the same web2py instance. Do you have any example? like: mydomain1 - /home/www-data/web2py/applications/myapp1 mydomain2 - /home/www-data/web2py/applications/myapp2 Thanks, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: package import
Did you restart web2py after upgrade? On Thursday, 21 March 2013 10:38:47 UTC-5, Phillipp Schmidt wrote: I just updated to this version, but I am still getting the error. Fany interface, though! Do you know any working packages that I could try to see whether it has something to do with my setup? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] how keepvalues if the page reload by the form don't even get submit?
Hello, I have a bizzard case where I need to set the number of input (more number of rows to be insert then inputs to be more precise) of a form... I create a bulk insert form that will insert many record at the same time but, if there is empty rows form will never submit since there is field in the row that can't be empty... So I need to let the user determine the number of input he needs... For more flexibility I would prefer the user to be allow to change the number of inputs (rows) while he is filling the form since he may have made a mistake in evaluation of the number of row he were needing if I only let him set this parameters before the form is generated... One solution is to create a factory form with one field number_of_inputs that could auto-submit once the number of inputs is select by a dropbox, then the page reload and I can force the regeneration of the seconde embeded form in the page to consider the new number_of_inputs parameters before redraw the form... With this approach I need to keep values that are already entered, but the second form should not be submitted since it is not completed and because of that I need a custom keep values feature that doesn't required the second form to be submit... Other solution, could be to embed the number_of_inputs into a unique form and parse only the first inputs until the max number of rows allowed by the number_of_inputs value... Not very possible without customizing form.accepts() I guess... Richard -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: package import
Yes, I restarted a couple of times. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: REF: Upload of Files
if request.vars.quotes_file: Sorry, I didn't realize this, but apparently if you do if [cgi.FieldStorage object] you get False rather than True, so instead try: if hasattr(request.vars.quotes_file, file): or import cgi if isinstance(request.vars.quotes_file, cgi.FieldStorage) I have further noticed this error in the page source after making a submit: var ajax_error_500 = 'An error occured, please a href=/testapp/default/index?first_name=bggfbfgamp;quotes_file=FieldStorage%28%27quotes_file%27%2C+%27rows+%282%29.csv%27%2C+%27circular.circular_no%2Ccircular.recipients%2Ccircular.circular_title%2Ccircular.circular_date%5Cr%5CnNAZ%2F1%2F2013%2CALL+MEMBERS+OF+STAFF%2CLunch+to+be+served+at+the+Motel%2C2013-03-01%5Cr%5Cn%27%29reload/a the page' That is not an error -- it is just a Javascript variable that is automatically generated by web2py_ajax.html. It is there in case there is an Ajax error on the page, in which case it will be used to generate an error message. However, I notice there is an error in the code used to generate that variable -- it should not be including post_vars in the link URL, only get_vars (I have submitted a patch to correct that). Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] postgres error
db.define_table('countries', Field('country_name') ) db.define_table('testing', Field('origin','reference countries',requires=IS_IN_DB(db,'countries.country_name',error_message='Choose origin country')) ) when i try to input testing from database administration, i get this error: class 'psycopg2.IntegrityError' insert or update on table testing violates foreign key constraint sea_inquery_origin_fkey DETAIL: Key (origin)=(0) is not present in table countries. any idea? i create different tables but get same result. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How to create a loop to add multiple child records
I'm glad you like it, and it's interesting, but this way is not secure, since it is susceptible to double submit and CSRF. I would only recommend this way if you are building an internal only website. You should probably have a formkey to protect against it. On Wednesday, March 20, 2013 6:44:16 PM UTC-7, 黄祥 wrote: this cool man, thanks derek hi alex, hope this can help for you to follow the web2py slices (much more simple than the one on the discussion that i've attached before): p.s. please focus on the bold *pwd* /web2py/applications/test *cat controllers/default.py* # -*- coding: utf-8 -*- # this file is released under public domain and you can use without limitations # ## This is a samples controller ## - index is the default action of any application ## - user is required for authentication and authorization ## - download is for downloading files uploaded in the db (does streaming) ## - call exposes all registered services (none by default) # *def index(): * *return dict(message=hello from houses.py)* * * *def display():* *people = db().select(db.person.ALL)** * *return dict(people = people)* * * *def showHouses():* *houses = db(db.house.person == request.vars.id).select(db.house.ALL)* *return dict(houses=houses)* * * *def saveAddress():* *if request.post_vars.address:* *newhouse = db.house.insert(address=request.post_vars.address, person=request.post_vars.owner)* *houses = db(db.house.person == request.post_vars.owner).select(db.house.ALL)* *return dict(houses=houses)* def user(): exposes: http:///[app]/default/user/login http:///[app]/default/user/logout http:///[app]/default/user/register http:///[app]/default/user/profile http:///[app]/default/user/retrieve_password http:///[app]/default/user/change_password use @auth.requires_login() @auth.requires_membership('group name') @auth.requires_permission('read','table name',record_id) to decorate functions that need access control return dict(form=auth()) def download(): allows downloading of uploaded files http:///[app]/default/download/[filename] return response.download(request, db) def call(): exposes services. for example: http:///[app]/default/call/jsonrpc decorate with @services.jsonrpc the functions to expose supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv return service() @auth.requires_signature() def data(): http:///[app]/default/data/tables http:///[app]/default/data/create/[table] http:///[app]/default/data/read/[table]/[id] http:///[app]/default/data/update/[table]/[id] http:///[app]/default/data/delete/[table]/[id] http:///[app]/default/data/select/[table] http:///[app]/default/data/search/[table] but URLs must be signed, i.e. linked with A('table',_href=URL('data/tables',user_signature=True)) or with the signed load operator LOAD('default','data.load',args='tables',ajax=True,user_signature=True) return dict(form=crud()) *cat models/db.py* # -*- coding: utf-8 -*- # ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations # ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client())) ## by default give a view/generic.extension to all actions from localhost ## none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] ## (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' # ## Here is sample code if you need for ## - email
Re: [web2py] auth.settings.logout_onlogout = lambda user: on_logout(auth,session)
I don't see any decaration of on_logout in web2py 2.3.2, search the book for on_logout lead to nothing either... Could it be your own custom function?? Richard On Thu, Mar 21, 2013 at 3:08 AM, Annet anneve...@googlemail.com wrote: After upgrading to web2py version 2.4.4 this no longer works: auth.settings.logout_onlogout = lambda user: on_logout(auth,session) I get the following error: global name 'on_logout' is not defined. on_logout(auth,session) is a function in a module which clears all the settings of the cms part of my application. Is there another way to call on_logout(auth,session) in web2py 2.4.4? Kind regards, Annet -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py and timezones
Massimo, I think you need a new keyboard, looks like your 'o' key is failing you. Either that, or the ring finger on your right hand has a problem. Twice now there's a missing 'o'. On Thursday, March 21, 2013 8:33:42 AM UTC-7, Massimo Di Pierro wrote: I have a major patch from Niphlod that replace my naive implementation with one based on pytz. I agree this is the way to go. We have two open issues: 1) should be include pytz in web2py r make it a depencency 2) should we do the pytz import in web2py or should we pass pytz objects to validators (the pytz would be defined outside of web2py), tus giving the option of not using pytz. On Thursday, 21 March 2013 05:28:09 UTC-5, mart wrote: hum... I use this and solves pretty much the bulk of the DLST issues that were problematic for me. http://pytz.sourceforge.net (its the Olsen TZ DB wrapped in python) I found it a little tricky at first, but once i got my head wrapped around the different permutations of dates (past, presents, different time zones, DLST, DT formats) i work with, things cleared up pretty quickly. Anyways, works for me. - Mart On Sunday, March 17, 2013 7:31:24 PM UTC-7, Massimo Di Pierro wrote: I was looking at code to detect the user timezone and store dates consistently in UTC format. I made some changes in trunk to handle this. I could use some help testing. 1) In the header of your layout.html add: {{if not session.timezone:}} script jQuery(function(){jQuery.post('{{=URL('default','set_timezone')}}',{timezone:(new Date()).getTimezoneOffset()});}); /script {{pass}} 2) in the default controller: def set_timezone(): session.timezone = int(request.vars.timezone)/60 3) Use the new timezone attribute of validators in trunk: Field('birthday','datetime',requires = IS_DATETIME(timezone=session.timezone) Does it work for you? Suggestions for improvement? Massimo -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: REF: Upload of Files
But the question again is where is the file stored, its not appearing in the specified uploads directory for manipulation. What I want to do is upload an excel sheet with specific columns of data, then get the data and insert into db with similar columns On Mar 21, 2013 6:48 PM, Anthony abasta...@gmail.com wrote: if request.vars.quotes_file: Sorry, I didn't realize this, but apparently if you do if [cgi.FieldStorage object] you get False rather than True, so instead try: if hasattr(request.vars.quotes_file, file): or import cgi if isinstance(request.vars.quotes_file, cgi.FieldStorage) I have further noticed this error in the page source after making a submit: var ajax_error_500 = 'An error occured, please a href=/testapp/default/index?**first_name=bggfbfgamp;quotes_** file=FieldStorage%28%27quotes_**file%27%2C+%27rows+%282%29.** csv%27%2C+%27circular.**circular_no%2Ccircular.**recipients%2Ccircular.** circular_title%2Ccircular.**circular_date%5Cr%5CnNAZ%2F1%** 2F2013%2CALL+MEMBERS+OF+STAFF%**2CLunch+to+be+served+at+the+** Motel%2C2013-03-01%5Cr%5Cn%27%**29reload/a the page' That is not an error -- it is just a Javascript variable that is automatically generated by web2py_ajax.html. It is there in case there is an Ajax error on the page, in which case it will be used to generate an error message. However, I notice there is an error in the code used to generate that variable -- it should not be including post_vars in the link URL, only get_vars (I have submitted a patch to correct that). Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Import MySQL module in Web2py on mac
I use Mac Os X Lion I open the web2py app directly for the server rather than using the terminal to open. I want to use MySQL database. SO where should I place the MySQL db module so that I can import it in the server. For a Windows System we can direclty copy the contents to site-packages folder. What should we do in case of mac? Thanks -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py and timezones
:-) On Thursday, 21 March 2013 12:51:26 UTC-5, Derek wrote: Massimo, I think you need a new keyboard, looks like your 'o' key is failing you. Either that, or the ring finger on your right hand has a problem. Twice now there's a missing 'o'. On Thursday, March 21, 2013 8:33:42 AM UTC-7, Massimo Di Pierro wrote: I have a major patch from Niphlod that replace my naive implementation with one based on pytz. I agree this is the way to go. We have two open issues: 1) should be include pytz in web2py r make it a depencency 2) should we do the pytz import in web2py or should we pass pytz objects to validators (the pytz would be defined outside of web2py), tus giving the option of not using pytz. On Thursday, 21 March 2013 05:28:09 UTC-5, mart wrote: hum... I use this and solves pretty much the bulk of the DLST issues that were problematic for me. http://pytz.sourceforge.net (its the Olsen TZ DB wrapped in python) I found it a little tricky at first, but once i got my head wrapped around the different permutations of dates (past, presents, different time zones, DLST, DT formats) i work with, things cleared up pretty quickly. Anyways, works for me. - Mart On Sunday, March 17, 2013 7:31:24 PM UTC-7, Massimo Di Pierro wrote: I was looking at code to detect the user timezone and store dates consistently in UTC format. I made some changes in trunk to handle this. I could use some help testing. 1) In the header of your layout.html add: {{if not session.timezone:}} script jQuery(function(){jQuery.post('{{=URL('default','set_timezone')}}',{timezone:(new Date()).getTimezoneOffset()});}); /script {{pass}} 2) in the default controller: def set_timezone(): session.timezone = int(request.vars.timezone)/60 3) Use the new timezone attribute of validators in trunk: Field('birthday','datetime',requires = IS_DATETIME(timezone=session.timezone) Does it work for you? Suggestions for improvement? Massimo -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Doing validation using sqlform grid onupdate or ondelete callbacks
Hi, I am having trouble finding the right way to do this : - I have a table, each row has an owner which is the only one allowed to edit or delete it - Ownership is represented thanks to auth_permission (permission 'owner') - I would like to use ondelete and onupdate callbacks to verify that the auth.user indeed owned the row, the test is working fine within the callback function. However I do not know how to properly stop the update or delete when the user does not own the row - I managed to make this work in a pretty ugly way I think by raising an Exception within the ondelete callback when the user is not allowed to remove the row - However I can't to it with update as the exception seems not to be catched ... Am I missing something ? Thanks for your help ! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: postgres error
class 'psycopg2.IntegrityError' insert or update on table testing violates foreign key constraint sea_inquery_origin_fkey DETAIL: Key (origin)=(0) is not present in table countries. Are you setting 0 value for the foreign key? If you are in the admin app, the insert form should not pass validation unless you specify an actual db record as reference. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: postgres error
the form is created by the admin app, no validation error, just i get this error for any insert with relation. i dont understand. On Thursday, March 21, 2013 10:06:54 PM UTC+3:30, Alan Etkin wrote: class 'psycopg2.IntegrityError' insert or update on table testing violates foreign key constraint sea_inquery_origin_fkey DETAIL: Key (origin)=(0) is not present in table countries. Are you setting 0 value for the foreign key? If you are in the admin app, the insert form should not pass validation unless you specify an actual db record as reference. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Mongodb error in appadmin
On 03/21/2013 08:06 PM, Alan Etkin wrote: I would love to have some pointers about how though define mongo in db.py in a proper nosql way. Could you open an issue at the project page? Done :-) Issue 1401 https://code.google.com/p/web2py/issues/detail?id=1401: Mongodb error in appadmin If more info needed or some testing is needed just ask. I will play with mongo and web2py anyway. If you can, please provide: - The relevant part of the model - A possible set of data which would reproduce the error - Your mongodb driver, database server, web2py and Python versions The MongoDB DAL adapter does some automatic type mapping for id fields. I belive the issue could be realted to that. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: postgres error
the form is created by the admin app, no validation error, just i get this error for any insert with relation. Wait, your model has something odd (at least for me) Since countries is a reference value, AFAIK, it must be an integer. But you are using a string validator. I don't think that's legal. If you remove the validator, it should work fine. I think you need to set the constraint in another way. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: postgres error
there is no string validator, i just use IS_IN_DB to create drop down widget On Thursday, March 21, 2013 10:26:38 PM UTC+3:30, Alan Etkin wrote: the form is created by the admin app, no validation error, just i get this error for any insert with relation. Wait, your model has something odd (at least for me) Since countries is a reference value, AFAIK, it must be an integer. But you are using a string validator. I don't think that's legal. If you remove the validator, it should work fine. I think you need to set the constraint in another way. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: postgres error
there is no string validator, i just use IS_IN_DB to create drop down widget Yes, sorry, I checked the api and it seems you are using the correct syntax. Does it work using IS_IN_DB (db, db.countries.country_name) instead? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] auth.settings.logout_onlogout = lambda user: on_logout(auth,session)
on trunk there is such a function, however it takes only user as a parameter if onlogout: onlogout(self.user) On Thursday, March 21, 2013 6:48:40 PM UTC+1, Richard wrote: I don't see any decaration of on_logout in web2py 2.3.2, search the book for on_logout lead to nothing either... Could it be your own custom function?? Richard On Thu, Mar 21, 2013 at 3:08 AM, Annet anne...@googlemail.comjavascript: wrote: After upgrading to web2py version 2.4.4 this no longer works: auth.settings.logout_onlogout = lambda user: on_logout(auth,session) I get the following error: global name 'on_logout' is not defined. on_logout(auth,session) is a function in a module which clears all the settings of the cms part of my application. Is there another way to call on_logout(auth,session) in web2py 2.4.4? Kind regards, Annet -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Smartgrid: tamanho (largura) das colunas?
Como posso alterar o tamanho (largura) das colunas do smartgrid? Obrigado Fernando -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Webfaction out of memory? Hardly seems possible
Can anyone shed light on this? Webfaction shut me down this morning at a very inconvenient time, claiming that I had exceeded my 256 Meg of memory. The had an output from ps -u ... that supposedly showed my 5 Apache workers had consumed ~ 50 meg each. I don't see how this is possible. The site has been in operation one week. I'm the only one who has used it for testing. I know Apache child processes grow with each request, but they start out at 4096 bytes and there were fewer than 3000 lines in all the log files added together. That averages out to an average growth of 85 kB per request. Thanks, Cliff Kachinske -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: postgres error
The syntax may be correct per the manual, but IS_IN_DB tells Postgres to create a foreign key constraint on the field. If you look at the tables with psql or pgadmin you will see this is so. A foreign key constraint is always on the primary key of the foreign table. It has to be this way to guarantee uniqueness. This will work: countries = [r.countryname for r in db(somequery).select(db.countries.countryname)] db.testing.origin.requires = IS_IN_SET(countries) On Thursday, March 21, 2013 3:36:51 PM UTC-4, Alan Etkin wrote: there is no string validator, i just use IS_IN_DB to create drop down widget Yes, sorry, I checked the api and it seems you are using the correct syntax. Does it work using IS_IN_DB (db, db.countries.country_name) instead? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] auth.settings.logout_onlogout = lambda user: on_logout(auth,session)
:~/version_232/web2py$ grep 'onlogout' * Return nothing!! Richard On Thu, Mar 21, 2013 at 3:43 PM, Niphlod niph...@gmail.com wrote: on trunk there is such a function, however it takes only user as a parameter if onlogout: onlogout(self.user) On Thursday, March 21, 2013 6:48:40 PM UTC+1, Richard wrote: I don't see any decaration of on_logout in web2py 2.3.2, search the book for on_logout lead to nothing either... Could it be your own custom function?? Richard On Thu, Mar 21, 2013 at 3:08 AM, Annet anne...@googlemail.com wrote: After upgrading to web2py version 2.4.4 this no longer works: auth.settings.logout_onlogout = lambda user: on_logout(auth,session) I get the following error: global name 'on_logout' is not defined. on_logout(auth,session) is a function in a module which clears all the settings of the cms part of my application. Is there another way to call on_logout(auth,session) in web2py 2.4.4? Kind regards, Annet -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Doing validation using sqlform grid onupdate or ondelete callbacks
I would do onvalidate. Then you can redirect before damage is done or you can do something like: form.errors['the_restricted_field'] = Gotcha!! What were you thinking? You cannot edit this record. Go away. You may wish to use a less abusive error message. On Thursday, March 21, 2013 2:26:10 PM UTC-4, Jean-Baptiste Fuzier wrote: Hi, I am having trouble finding the right way to do this : - I have a table, each row has an owner which is the only one allowed to edit or delete it - Ownership is represented thanks to auth_permission (permission 'owner') - I would like to use ondelete and onupdate callbacks to verify that the auth.user indeed owned the row, the test is working fine within the callback function. However I do not know how to properly stop the update or delete when the user does not own the row - I managed to make this work in a pretty ugly way I think by raising an Exception within the ondelete callback when the user is not allowed to remove the row - However I can't to it with update as the exception seems not to be catched ... Am I missing something ? Thanks for your help ! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] auth.settings.logout_onlogout = lambda user: on_logout(auth,session)
if you search with grep you should do it recursively grep -nR 'onlogout' * R for recursively, n for the line number. On Thursday, March 21, 2013 9:03:55 PM UTC+1, Richard wrote: :~/version_232/web2py$ grep 'onlogout' * Return nothing!! Richard On Thu, Mar 21, 2013 at 3:43 PM, Niphlod nip...@gmail.com javascript:wrote: on trunk there is such a function, however it takes only user as a parameter if onlogout: onlogout(self.user) On Thursday, March 21, 2013 6:48:40 PM UTC+1, Richard wrote: I don't see any decaration of on_logout in web2py 2.3.2, search the book for on_logout lead to nothing either... Could it be your own custom function?? Richard On Thu, Mar 21, 2013 at 3:08 AM, Annet anne...@googlemail.com wrote: After upgrading to web2py version 2.4.4 this no longer works: auth.settings.logout_onlogout = lambda user: on_logout(auth,session) I get the following error: global name 'on_logout' is not defined. on_logout(auth,session) is a function in a module which clears all the settings of the cms part of my application. Is there another way to call on_logout(auth,session) in web2py 2.4.4? Kind regards, Annet -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: postgres error
just to clear out doubts. a field 'reference sometable' gets: - a foreign key to the id of sometable - a validator that by default builds up on the format argument of sometable you CAN'T have a foreign key to a table and have the requires parameter with is_in_db() building a string value. So, if you want the 'origin' field to store the integer that is a pointer to the countries.id table, while retaining the country_name while representing it in the dropdown, you should do db.define_table('countries', Field('country_name'), format='%(country_name)s' ) db.define_table('testing', Field('origin','reference countries') ) or db.define_table('countries', Field('country_name'), ) db.define_table('testing', Field('origin','reference countries',requires=IS_IN_DB( db,'countries.id', '%(country_name)s',error_message='Choose origin country' )) ) if you want testing.origin to be a string holding country names (so, not a reference), with the dropdown showing the countries you have in the countries table db.define_table('countries', Field('country_name'), ) db.define_table('testing', Field('origin',requires=IS_IN_DB( db,'countries.country_name',error_message='Choose origin country')) ) tl;dr your mix and match doesn't specify what you want. Field type trumps the requires parameter on a database level. On Thursday, March 21, 2013 9:02:20 PM UTC+1, Cliff Kachinske wrote: The syntax may be correct per the manual, but IS_IN_DB tells Postgres to create a foreign key constraint on the field. If you look at the tables with psql or pgadmin you will see this is so. A foreign key constraint is always on the primary key of the foreign table. It has to be this way to guarantee uniqueness. This will work: countries = [r.countryname for r in db(somequery).select(db.countries.countryname)] db.testing.origin.requires = IS_IN_SET(countries) On Thursday, March 21, 2013 3:36:51 PM UTC-4, Alan Etkin wrote: there is no string validator, i just use IS_IN_DB to create drop down widget Yes, sorry, I checked the api and it seems you are using the correct syntax. Does it work using IS_IN_DB (db, db.countries.country_name) instead? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] auth.settings.logout_onlogout = lambda user: on_logout(auth,session)
Forgot! Sorry for the noise... So with w2p 2.3.2 get onlogout and logout_onlogout So Annet must have a mistake in his code or the on_logout change for onlogout I guess... Richard On Thu, Mar 21, 2013 at 4:16 PM, Niphlod niph...@gmail.com wrote: if you search with grep you should do it recursively grep -nR 'onlogout' * R for recursively, n for the line number. On Thursday, March 21, 2013 9:03:55 PM UTC+1, Richard wrote: :~/version_232/web2py$ grep 'onlogout' * Return nothing!! Richard On Thu, Mar 21, 2013 at 3:43 PM, Niphlod nip...@gmail.com wrote: on trunk there is such a function, however it takes only user as a parameter if onlogout: onlogout(self.user) On Thursday, March 21, 2013 6:48:40 PM UTC+1, Richard wrote: I don't see any decaration of on_logout in web2py 2.3.2, search the book for on_logout lead to nothing either... Could it be your own custom function?? Richard On Thu, Mar 21, 2013 at 3:08 AM, Annet anne...@googlemail.com wrote: After upgrading to web2py version 2.4.4 this no longer works: auth.settings.logout_onlogout = lambda user: on_logout(auth,session) I get the following error: global name 'on_logout' is not defined. on_logout(auth,session) is a function in a module which clears all the settings of the cms part of my application. Is there another way to call on_logout(auth,session) in web2py 2.4.4? Kind regards, Annet -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@**googlegroups.com. For more options, visit https://groups.google.com/**grou**ps/opt_outhttps://groups.google.com/groups/opt_out . -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: postgres error
My bad. How could I not remember that? On Thursday, March 21, 2013 4:27:40 PM UTC-4, Niphlod wrote: just to clear out doubts. a field 'reference sometable' gets: - a foreign key to the id of sometable - a validator that by default builds up on the format argument of sometable you CAN'T have a foreign key to a table and have the requires parameter with is_in_db() building a string value. So, if you want the 'origin' field to store the integer that is a pointer to the countries.id table, while retaining the country_name while representing it in the dropdown, you should do db.define_table('countries', Field('country_name'), format='%(country_name)s' ) db.define_table('testing', Field('origin','reference countries') ) or db.define_table('countries', Field('country_name'), ) db.define_table('testing', Field('origin','reference countries',requires=IS_IN_DB( db,'countries.id', '%(country_name)s',error_message='Choose origin country')) ) if you want testing.origin to be a string holding country names (so, not a reference), with the dropdown showing the countries you have in the countries table db.define_table('countries', Field('country_name'), ) db.define_table('testing', Field('origin',requires=IS_IN_DB( db,'countries.country_name',error_message='Choose origin country')) ) tl;dr your mix and match doesn't specify what you want. Field type trumps the requires parameter on a database level. On Thursday, March 21, 2013 9:02:20 PM UTC+1, Cliff Kachinske wrote: The syntax may be correct per the manual, but IS_IN_DB tells Postgres to create a foreign key constraint on the field. If you look at the tables with psql or pgadmin you will see this is so. A foreign key constraint is always on the primary key of the foreign table. It has to be this way to guarantee uniqueness. This will work: countries = [r.countryname for r in db(somequery).select(db.countries.countryname)] db.testing.origin.requires = IS_IN_SET(countries) On Thursday, March 21, 2013 3:36:51 PM UTC-4, Alan Etkin wrote: there is no string validator, i just use IS_IN_DB to create drop down widget Yes, sorry, I checked the api and it seems you are using the correct syntax. Does it work using IS_IN_DB (db, db.countries.country_name) instead? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Webfaction out of memory? Hardly seems possible
I am also having memory issues on dreamhost VPS... only 3 people accessing it... On Thu, Mar 21, 2013 at 4:46 PM, Cliff Kachinske cjk...@gmail.com wrote: Can anyone shed light on this? Webfaction shut me down this morning at a very inconvenient time, claiming that I had exceeded my 256 Meg of memory. The had an output from ps -u ... that supposedly showed my 5 Apache workers had consumed ~ 50 meg each. I don't see how this is possible. The site has been in operation one week. I'm the only one who has used it for testing. I know Apache child processes grow with each request, but they start out at 4096 bytes and there were fewer than 3000 lines in all the log files added together. That averages out to an average growth of 85 kB per request. Thanks, Cliff Kachinske -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: REF: Upload of Files
Recall that the suggestions to forego calling form.process() and instead just check for and directly manipulate request.vars.quotes_file was assuming you did not want to permanently store the file. If you do want to keep the file, then you should call form.process() (or include code to manually save the file). However, it's not clear that you do really need to keep the file. Presumably whatever code you plan to use to process and store the data would first open the file and then work with the open file object -- instead, you should be able to work with the FieldStorage file object directly (i.e., request.vars.quotes_file.file). Anthony On Thursday, March 21, 2013 2:01:01 PM UTC-4, software.ted wrote: But the question again is where is the file stored, its not appearing in the specified uploads directory for manipulation. What I want to do is upload an excel sheet with specific columns of data, then get the data and insert into db with similar columns On Mar 21, 2013 6:48 PM, Anthony abas...@gmail.com javascript: wrote: if request.vars.quotes_file: Sorry, I didn't realize this, but apparently if you do if [cgi.FieldStorage object] you get False rather than True, so instead try: if hasattr(request.vars.quotes_file, file): or import cgi if isinstance(request.vars.quotes_file, cgi.FieldStorage) I have further noticed this error in the page source after making a submit: var ajax_error_500 = 'An error occured, please a href=/testapp/default/index?**first_name=bggfbfgamp;quotes_** file=FieldStorage%28%27quotes_**file%27%2C+%27rows+%282%29.** csv%27%2C+%27circular.**circular_no%2Ccircular.**recipients%2Ccircular.* *circular_title%2Ccircular.**circular_date%5Cr%5CnNAZ%2F1%** 2F2013%2CALL+MEMBERS+OF+STAFF%**2CLunch+to+be+served+at+the+** Motel%2C2013-03-01%5Cr%5Cn%27%**29reload/a the page' That is not an error -- it is just a Javascript variable that is automatically generated by web2py_ajax.html. It is there in case there is an Ajax error on the page, in which case it will be used to generate an error message. However, I notice there is an error in the code used to generate that variable -- it should not be including post_vars in the link URL, only get_vars (I have submitted a patch to correct that). Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Embed MP3 audio player in HTML via web2py
Check out my app at wwwgong.pythonanywhere.com/rpad I embed video mp3 and img I can share the code if interested -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Doing validation using sqlform grid onupdate or ondelete callbacks
Hi There are some easy ways to do it. If the owner reference is in the row you can use before and after callbackshttp://www.web2py.com/books/default/chapter/29/06#before-and-after-callbacks something like: db.mytable._before_update.append(lambda s,r: True if r.owner == auth.user_id else False) The True value cancels the insert Also you can use Authorizationhttp://www.web2py.com/books/default/chapter/29/09#Authorization rows = db(auth.accessible_query('update', db.mytable, user_id)) .select(db.mytable.ALL) I like the Authorization choice because its a nice abstraction and you dont need to mess with forms or tables 21 de marzo de 2013 19:26:10 UTC+1, Jean-Baptiste Fuzier escribió: Hi, I am having trouble finding the right way to do this : - I have a table, each row has an owner which is the only one allowed to edit or delete it - Ownership is represented thanks to auth_permission (permission 'owner') - I would like to use ondelete and onupdate callbacks to verify that the auth.user indeed owned the row, the test is working fine within the callback function. However I do not know how to properly stop the update or delete when the user does not own the row - I managed to make this work in a pretty ugly way I think by raising an Exception within the ondelete callback when the user is not allowed to remove the row - However I can't to it with update as the exception seems not to be catched ... Am I missing something ? Thanks for your help ! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] auth.settings.logout_onlogout = lambda user: on_logout(auth,session)
No, there is no onlogout function in web2py (either in globals or in the Auth class). Rather, the logout() function takes an onlogout argument, which is a callable -- so this code: if onlogout: onlogout(self.user) is inside the logout() function, and the onlogout referenced there is the onlogout argument passed to logout() (though it defaults to self.settings.logout_onlogout if not directly passed in to logout()). It appears that Annet has her own on_logout (not onlogout) function defined in a module. Presumably the error is occurring because it is not getting imported (who knows why without seeing some code). Anthony On Thursday, March 21, 2013 4:36:24 PM UTC-4, Richard wrote: Forgot! Sorry for the noise... So with w2p 2.3.2 get onlogout and logout_onlogout So Annet must have a mistake in his code or the on_logout change for onlogout I guess... Richard On Thu, Mar 21, 2013 at 4:16 PM, Niphlod nip...@gmail.com javascript:wrote: if you search with grep you should do it recursively grep -nR 'onlogout' * R for recursively, n for the line number. On Thursday, March 21, 2013 9:03:55 PM UTC+1, Richard wrote: :~/version_232/web2py$ grep 'onlogout' * Return nothing!! Richard On Thu, Mar 21, 2013 at 3:43 PM, Niphlod nip...@gmail.com wrote: on trunk there is such a function, however it takes only user as a parameter if onlogout: onlogout(self.user) On Thursday, March 21, 2013 6:48:40 PM UTC+1, Richard wrote: I don't see any decaration of on_logout in web2py 2.3.2, search the book for on_logout lead to nothing either... Could it be your own custom function?? Richard On Thu, Mar 21, 2013 at 3:08 AM, Annet anne...@googlemail.com wrote: After upgrading to web2py version 2.4.4 this no longer works: auth.settings.logout_onlogout = lambda user: on_logout(auth,session) I get the following error: global name 'on_logout' is not defined. on_logout(auth,session) is a function in a module which clears all the settings of the cms part of my application. Is there another way to call on_logout(auth,session) in web2py 2.4.4? Kind regards, Annet -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@**googlegroups.com. For more options, visit https://groups.google.com/**grou**ps/opt_outhttps://groups.google.com/groups/opt_out . -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Access data in PUT request for @request.restful()
Hi, How can I access the data in the PUT request? (in the body of the request) Can this be automatically parsed (my data is JSON) Thanks, Daniel -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] record representation format that refer to another table and that table is refer to another table
hi, did anyone know how to show record representation format that refer to another table and that table is refer to another table? e.g. *db.py* db.define_table('branch', Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone'), Field('fax'), Field('email'), Field('company', 'reference company'), format='%(address)s') db.define_table('room', Field('room_no'), Field('status', 'list:string'), Field('branch', 'reference branch'), format='%(branch)s %(room_no)s') db.define_table('booking', Field('scheduled_start', 'datetime'), Field('due_date', 'datetime'), Field('room', 'reference room'), Field('customer', 'reference customer'), Field('description', 'text'), format='%(scheduled_start)s %(customer)s %(room)s') *my question is:* when i select table booking, i want to see : branch address room no (e.g. jakarta 101), notf branch id room no (e.g. 1 101). many thanks before -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: record representation format that refer to another table and that table is refer to another table
The format attribute does propagate, so you'll have to write your own represent function for the room field (not tested): Field('room', 'reference room', represent=lambda id, r: '%s %s' % (r.room. branch.address, r.room.room_no)) The above represent function uses recursive selects, which I think should work. Anthony On Thursday, March 21, 2013 11:30:34 PM UTC-4, 黄祥 wrote: hi, did anyone know how to show record representation format that refer to another table and that table is refer to another table? e.g. *db.py* db.define_table('branch', Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone'), Field('fax'), Field('email'), Field('company', 'reference company'), format='%(address)s') db.define_table('room', Field('room_no'), Field('status', 'list:string'), Field('branch', 'reference branch'), format='%(branch)s %(room_no)s') db.define_table('booking', Field('scheduled_start', 'datetime'), Field('due_date', 'datetime'), Field('room', 'reference room'), Field('customer', 'reference customer'), Field('description', 'text'), format='%(scheduled_start)s %(customer)s %(room)s') *my question is:* when i select table booking, i want to see : branch address room no (e.g. jakarta 101), notf branch id room no (e.g. 1 101). many thanks before -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Any Apache wizard - another dumb question
My Webfaction account uses Apache with workers for MPM. It seems that any memory allocated to a process spawned by an Apache worker actually clings to that worker after the process finishes. That's why there is a maximum_requests_per_worker directive. Could it be that big database migrations cause huge memory allocations across most of the available Apache workers? Thank you, Cliff Kachinske -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Pythonanywhere down today?
The Python anywhere web site was down earlier today. Were the hosted apps down at the same time? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Access data in PUT request for @request.restful()
if request.env.request_method=='POST': put_vars = request.post_vars basically request.post_vars are the variables in body whether it is PUT or POST or other. On Thursday, 21 March 2013 19:10:27 UTC-5, Daniel Gonzalez wrote: Hi, How can I access the data in the PUT request? (in the body of the request) Can this be automatically parsed (my data is JSON) Thanks, Daniel -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: record representation format that refer to another table and that table is refer to another table
it's work well, thank you very much anthony. it seems the 'represent' can't work in validators : requires. actually i'm also want the represent format in the form too. when i try to use the represent in requires an error is occured. did you know how to do it in requires field? when using : db.booking.room.requires=IS_IN_DB(db(db.room.status=='Available'), db.room.id, represent=lambda id, r: '%s %s' % (r.room.branch.address, r.room.room_no)) Traceback 1. 2. 3. 4. 5. 6. 7. Traceback (most recent call last): File /home/stifank/Desktop/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/stifank/Desktop/web2py/applications/hotel/models/db_wizard_requires.py, line 57, in module represent=lambda id, r: '%s %s' % (r.room.branch.address, r.room.room_no)) TypeError: __init__() got an unexpected keyword argument 'represent' when using : db.booking.room.requires=IS_IN_DB(db(db.room.status=='Available'), db.room.id, lambda id, r: '%s %s' % (r.room.branch.address, r.room.room_no)) Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. Traceback (most recent call last): File /home/stifank/Desktop/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/stifank/Desktop/web2py/applications/hotel/controllers/default.py http://127.0.0.1:8000/admin/default/edit/futsal/controllers/default.py, line 181, in module File /home/stifank/Desktop/web2py/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/stifank/Desktop/web2py/gluon/tools.py, line 2971, in f return action(*a, **b) File /home/stifank/Desktop/web2py/applications/hotel/controllers/default.py http://127.0.0.1:8000/admin/default/edit/futsal/controllers/default.py, line 99, in booking editable=has_membership, deletable=has_membership) File /home/stifank/Desktop/web2py/gluon/sqlhtml.py, line 2084, in grid search_menu = SQLFORM.search_menu(sfields, prefix=prefix) File /home/stifank/Desktop/web2py/gluon/sqlhtml.py, line 1663, in search_menu for k,v in field.requires.options()], File /home/stifank/Desktop/web2py/gluon/validators.py, line 545, in options self.build_set() File /home/stifank/Desktop/web2py/gluon/validators.py, line 542, in build_set self.labels = [self.label(r) for r in records] TypeError: lambda() takes exactly 2 arguments (1 given) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: record representation format that refer to another table and that table is refer to another table
No, IS_IN_DB does not take a represent argument, but it does take a label argument that works similarly (though the lambda takes only a single argument -- the record): IS_IN_DB(db(db.room.status=='Available'), db.room.id, label=lambda r: '%s %s' % (r.room.branch.address, r.room.room_no)) Actually, you can optionally specify the represent function to take only a single argument as well, so you could just define the function once and use it in both places: def format_room(record): return '%s %s' % (record.room.branch.address, rrecord.room.room_no) Then do Field(..., represent=format_room) and IS_IN_DB(..., label=format_room). Anthony On Friday, March 22, 2013 1:06:22 AM UTC-4, 黄祥 wrote: it's work well, thank you very much anthony. it seems the 'represent' can't work in validators : requires. actually i'm also want the represent format in the form too. when i try to use the represent in requires an error is occured. did you know how to do it in requires field? when using : db.booking.room.requires=IS_IN_DB(db(db.room.status=='Available'), db.room.id, represent=lambda id, r: '%s %s' % (r.room.branch.address, r.room.room_no)) Traceback 1. 2. 3. 4. 5. 6. 7. Traceback (most recent call last): File /home/stifank/Desktop/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/stifank/Desktop/web2py/applications/hotel/models/db_wizard_requires.py, line 57, in module represent=lambda id, r: '%s %s' % (r.room.branch.address, r.room.room_no)) TypeError: __init__() got an unexpected keyword argument 'represent' when using : db.booking.room.requires=IS_IN_DB(db(db.room.status=='Available'), db.room.id, lambda id, r: '%s %s' % (r.room.branch.address, r.room.room_no)) Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. Traceback (most recent call last): File /home/stifank/Desktop/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/stifank/Desktop/web2py/applications/hotel/controllers/default.py http://127.0.0.1:8000/admin/default/edit/futsal/controllers/default.py, line 181, in module File /home/stifank/Desktop/web2py/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/stifank/Desktop/web2py/gluon/tools.py, line 2971, in f return action(*a, **b) File /home/stifank/Desktop/web2py/applications/hotel/controllers/default.py http://127.0.0.1:8000/admin/default/edit/futsal/controllers/default.py, line 99, in booking editable=has_membership, deletable=has_membership) File /home/stifank/Desktop/web2py/gluon/sqlhtml.py, line 2084, in grid search_menu = SQLFORM.search_menu(sfields, prefix=prefix) File /home/stifank/Desktop/web2py/gluon/sqlhtml.py, line 1663, in search_menu for k,v in field.requires.options()], File /home/stifank/Desktop/web2py/gluon/validators.py, line 545, in options self.build_set() File /home/stifank/Desktop/web2py/gluon/validators.py, line 542, in build_set self.labels = [self.label(r) for r in records] TypeError: lambda() takes exactly 2 arguments (1 given) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.