Re: [web2py] Re: preferred solution for parsing {xht,ht,x}ml
lxml, beautifulsoup --
[web2py] web2py and crawlers
i was wondering, if i wrote a crawler in modules to populate a database table, how would the crawler run? as in how to run that script? --
[web2py] Re: Uploading images
Hello Alan, Thank you very much for your answer. Finally, based on your note ( ... renames uploaded files (to prevent directory traversal attacks) ...), in the difficulty of the changes, and taking into account that the rename is not very necessary in fact, I've decided not to change the name of the uploaded files. Now I upload and retrieve the images with the code Massimo gave me and the download() function you say. Thank you very much for the help! El lunes, 7 de enero de 2013 02:19:03 UTC+1, Alan Etkin escribió: This makes me think, is there any way so the stored file is accessed directly via URL, something like http://mysite.com/myapp/uploads/myfilename.jpg? This should customize the uploaded files. - Retrieve the file db record - Change the upload field to whatever name you need - Rename the file with the Python os library The name change is a security measure: ... renames uploaded files (to prevent directory traversal attacks) ... Note that the download() function restores the original filename on client downloads --
Re: [web2py] Changed date to datetime. Now I get: invalid literal for int() with base 10:
When you delete a sqlite database, make sure you delete all the associated .table files too. On Sunday, 6 January 2013 20:45:34 UTC-6, HittingSmoke wrote: Yep, SQLITE. But I completely wiped the database from the disk in web2py/applications/application/databases and let web2py write a completely new one. Wouldn't I not need to alter anything if web2py has created a fresh database with the proper field types? On Sunday, January 6, 2013 6:37:48 PM UTC-8, rochacbruno wrote: Are you using SQLITE? SQLITE does not support alter table for changing column types. SO you have to use sqliteman program to alter directly on sqlite. --
[web2py] Re: web2py and crawlers
You can try: python web2py.py -S yourapp -M -R yourscript.py use -h for command line options On Monday, 7 January 2013 04:25:13 UTC-6, sasogeek wrote: i was wondering, if i wrote a crawler in models to populate a database table, how would the crawler run? as in how to run that script? --
[web2py] How do I get last n rows from table?
I want my controller to return the last ('updated') n rows given de definition below given a certain 'gid' and 'sid'. Can anyone help me? Thanks a lot in advance! Hans db.define_table('value', Field('gid', 'string'), Field('sid', 'string'), Field('value', 'integer', required=True), Field('updated', 'datetime', default=request.now, writable=False, readable=False), format = '%(value)s') --
[web2py] subforms / formsets / form cloning imprementation
Hello everybody! I'm quite new to Python and web2py, but I consumed all of web2py's wonderful documentation at the last few days and I'm quite amazed at this wonderful framework. But there's a feature that I need that I couldn't find a way to easily implement it. The application that I'm developing requires extensive use of form cloning within a single web page, done dynamically at the client side. I'm not really sure how to call this technique, so I found a bit hard to find information regarding this at this mailing list's archive. What I want to accomplish can be easily understood viewing the screenshots from this tool: http://www.mdelrosso.com/sheepit/ I already have my own (ugly) jquery code to create the forms dynamically, and of course I could validate it manually on web2py's side, but I was looking into an easier implementation using something like FORM or SQLFORM. Like I said, I'm very new to web2py and python, and I have no idea how django works, but I think I need to accomplish something similar to this: https://docs.djangoproject.com/en/dev/topics/forms/formsets/ I tried searching this mailing list archive and I found a couple of discussions from people trying to do the same thing, but I didn't find a solution. https://groups.google.com/forum/#!topic/web2py/ssaSj6v9Wu8/discussion https://groups.google.com/d/topic/web2py/UK8NZ1VMlNk/discussion But these are threads from 2011 There's also this guy asking something similar a couple of months ago: https://groups.google.com/d/topic/web2py/IPMz4FylT2k/discussion and http://stackoverflow.com/questions/13215902/web2py-possible-to-submit-multiple-forms-with-a-single-submit-button/13215926#13215926 but the solution presented didn't seem very elegant. Anyway, I would really appreciate any help on this. Thanks, Henrique. --
[web2py] Re: web2py and crawlers
the app is on an online server... http://sasogeek.pythonanywhere.com/newup/ will it work with that still work? On Monday, 7 January 2013 11:15:51 UTC, Massimo Di Pierro wrote: You can try: python web2py.py -S yourapp -M -R yourscript.py use -h for command line options On Monday, 7 January 2013 04:25:13 UTC-6, sasogeek wrote: i was wondering, if i wrote a crawler in models to populate a database table, how would the crawler run? as in how to run that script? --
[web2py] Re: How do I get last n rows from table?
tb = db.value db((tb.gid == 'something') (tb.sid == 'othersomething')).select(orderby=~ tb.updated, limitby=(0, 10)) will give you the last 10 On Monday, January 7, 2013 10:20:06 AM UTC+1, Hans Cr wrote: I want my controller to return the last ('updated') n rows given de definition below given a certain 'gid' and 'sid'. Can anyone help me? Thanks a lot in advance! Hans db.define_table('value', Field('gid', 'string'), Field('sid', 'string'), Field('value', 'integer', required=True), Field('updated', 'datetime', default=request.now, writable=False, readable=False), format = '%(value)s') --
[web2py] Re: How do I get last n rows from table?
Thanks! Works great! On Monday, January 7, 2013 12:33:19 PM UTC+1, Niphlod wrote: tb = db.value db((tb.gid == 'something') (tb.sid == 'othersomething')).select(orderby =~tb.updated, limitby=(0, 10)) will give you the last 10 On Monday, January 7, 2013 10:20:06 AM UTC+1, Hans Cr wrote: I want my controller to return the last ('updated') n rows given de definition below given a certain 'gid' and 'sid'. Can anyone help me? Thanks a lot in advance! Hans db.define_table('value', Field('gid', 'string'), Field('sid', 'string'), Field('value', 'integer', required=True), Field('updated', 'datetime', default=request.now, writable=False, readable=False), format = '%(value)s') --
[web2py] How do I get last row for each type from table?
I want my controller to return the last ('updated') row for each 'sid', given a specified 'gid'. 'sid' is multiple times in the table, but I want to have the last row. Can anyone help me? Thanks a lot in advance! Hans db.define_table('value', Field('gid', 'string'), Field('sid', 'string'), Field('value', 'integer', required=True), Field('updated', 'datetime', default=request.now, writable=False, readable=False), format = '%(value)s') --
[web2py] self join on postgres
Hi all, I've problems on defining self join queries on postgres, the query, works on sqlite, is defined as follows: start = db.record.with_alias('start') end = db.record.with_alias('end') query = ((start.station_id == 11) (end.station_id == 12)) rows = db( query ).select(start.gathered_on,start.mac, end.gathered_on, end. mac, orderby=start.gathered_on.epoch(), left= start.on( (start.mac == end.mac) )) The table is: db.define_table('record', Field('station_id', 'reference station'), Field('log_id', 'reference log'), Field('mac'), Field('gathered_on', 'datetime'), ) The generated query is: SELECT start.gathered_on, start.mac, end.gathered_on, end.mac FROM record AS end LEFT JOIN record AS start ON (start.mac = end.mac) WHERE ((start.station_id = 11) AND (end.station_id = 12)) ORDER BY EXTRACT(epoch FROM start.gathered_on); and it fails raising the following error: Traceback (most recent call last): File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/paolo/Dropbox/git/web2py/applications/vtraffic/controllers/default.py http://127.0.0.1:8000/admin/default/edit/vtraffic/controllers/default.py, line 655, in module File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in lambda self._caller = lambda f: f() File /home/paolo/Dropbox/git/web2py/applications/vtraffic/controllers/default.py http://127.0.0.1:8000/admin/default/edit/vtraffic/controllers/default.py, line 37, in index left= start.on( (start.mac == end.mac) )) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 8966, in select return adapter.select(self.query,fields,attributes) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1636, in select return self._select_aux(sql,fields,attributes) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1601, in _select_aux self.execute(sql) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1714, in execute return self.log_execute(*a, **b) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1708, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: syntax error at or near end LINE 1: SELECT start.gathered_on, start.mac, end.gathered_on, end.m... What should I have to do? Regards, Paolo --
[web2py] Re: cpdb errors
hum... you should just remove the quotes around the connection strings (options -y and -Y) since they are already strings when passed in. Otherwise, argparse will do this: ' sqlite://storage.sqlite' and then dal will not be able to open the DB. So, no quotes, should fix the problem. -y sqlite://storage.sqlite -Y postgres://postgres:password@ localhost:5432/db_target I haven't run this in a long time, but just tried it and it ran just fine. Note, the -d option is pointing to a recent dal.py which i simply dumped in the /Users/mart directory. I don't have a windows machine, but I think i can find one at work tomorrow and see if it behaves differently. guimauve:src mart$ python cpdb.py -f db_storage/cvs -d /Users/mart -y sqlite://auth_storage.sqlite -Y sqlite://storage2.sqlite -F db_storage/cvs_2 gluon path not found creating tables... exporting data... importing data... done! Attention: do not run this program again or you end up with duplicate records guimauve:src mart$ BTW - @ user backseat: Perhaps a little late, but I just noticed now... same goes for you, the quotes need to be removed. If the manual says sqlite://storage.sqlite for options -y and -Y, then that should be simply be corrected. Hope it helps, Mart On Sunday, January 6, 2013 10:03:46 PM UTC-8, Simon Ashley wrote: Interesting but encountering similar problems to *backseat *on windows 7 using the following command from a prompt in web2py root folder: i.e. c:\web2py set path=%path%;c:\web2py\gluon c:\web2py c:\python27\python scripts\cpdb.py -d gluon -f application\app\databases -y 'sqlite://storage.sqlite' -Y 'postgres://postgres:password@localhost:5432/db_target' It ends up with the attached errors, implying more path issues: https://lh5.googleusercontent.com/-kslYmw5agt4/UOpg5uzEtNI/AGs/suKvc8G0x8Q/s1600/copy+database1.png Can anyone suggest windows commands/ path's that may work? (Noted the Aptana environment solution, but have a time frame issue. Otherwise may have to go back to backseat's solution of individual exports/ imports) On Saturday, May 26, 2012 11:32:20 PM UTC+10, mart wrote: the first message is expected because of this import: try: from gluon import DAL except ImportError as err: print('gluon path not found') It wants to assume that that gluon is already loaded as part of the web2py environment (or as part of some other environment, like Aptana for example) and that you already have /gluon in your path (maybe even hard coded). If the gluon path is not set, well, you will get that gluon path not found message and the -d option will be expected. Because the -d option is expecting a *relative* path, your cmd line args will look different depending on the environment in which you are running the script. Hum... I guess being relative is relative ;) So, as an example, if you were to run this cmd from a simple bash shell (outside of any dev environment, or outside of a web2py context), you would simply cd and drill down into .../blabla/.../web2py/scripts/. In which case, your -d option would look like this: -d ../gluon. I just did this, and it all worked fine: macMart:Documents mart$ cd Aptana\ Studio\ Workspace/_p4/src/web2py/scripts/ macMart:scripts mart$ python cpdb.py -f ../../db_storage -d ../gluon -y sqlite://storage.sqlite -Y sqlite://storage2.sqlite -F ../../db_storage2 gluon path not found== THIS IS AN EXPECTED MESSAGE creating tables... exporting data... importing data... done! Hope it helps and that it makes sense! Mart :) On Thursday, May 17, 2012 2:00:08 AM UTC-7, backseat wrote: I'm trying to copy a database from Sqlite to MySQL using the cpdb.py script. In the manual, it states: cd web2py python scripts/cpdb.py \ -f applications/app/databases \ -y 'sqlite://storage.sqlite' \ -Y 'postgresql://username:password@hocalhost/mydb' However, if I do that I get gluon path not found. The help file suggests that I can specify the path to dal.py with -d, but: python scripts/cpdb.py -d gluon/dal.py -f applications/pytrack2/databases -y 'sqlite://storage.sqlite' -Y 'mysql://pytrack2:pytrack2@localhost/pytrack2' gluon path not found EXCEPTION: could not set DAL No module named dal If I use '-d gluon', it's better but now fails with a MySQL error (which I think relates to foreign keys), although it still gives the 'gluon path not found' error: $ python scripts/cpdb.py -d gluon -f applications/pytrack2/databases -y 'sqlite://storage.sqlite' -Y 'mysql://pytrack2:pytrack2@localhost/pytrack2' gluon path not found creating tables... EXCEPTION: could not make a copy of the database (1005, uCan't create table 'pytrack2.t_companies_archive' (errno: 150)) I'm going to continue by migrating by hand; if I should report this elsewhere or if you need more details, let me know. -- You can have everything in life you want
Re: [web2py] How do I get last row for each type from table?
Try using groupby clause. On Mon, Jan 7, 2013 at 10:19 AM, Hans Cr cloudsens...@gmail.com wrote: I want my controller to return the last ('updated') row for each 'sid', given a specified 'gid'. 'sid' is multiple times in the table, but I want to have the last row. Can anyone help me? Thanks a lot in advance! Hans db.define_table('value', Field('gid', 'string'), Field('sid', 'string'), Field('value', 'integer', required=True), Field('updated', 'datetime', default=request.now, writable=False, readable=False), format = '%(value)s') -- --
[web2py] Re: self join on postgres
did you try changing start and end as aliases ? while start on postgresql isn't reserved ( but is a reserved keyword for t-sql:2003 and t-sql:1999), end is reserved even for postgresql. On Monday, January 7, 2013 1:21:27 PM UTC+1, Paolo valleri wrote: Hi all, I've problems on defining self join queries on postgres, the query, works on sqlite, is defined as follows: start = db.record.with_alias('start') end = db.record.with_alias('end') query = ((start.station_id == 11) (end.station_id == 12)) rows = db( query ).select(start.gathered_on,start.mac, end.gathered_on, end.mac, orderby=start.gathered_on.epoch(), left= start.on( (start.mac == end.mac) )) The table is: db.define_table('record', Field('station_id', 'reference station'), Field('log_id', 'reference log'), Field('mac'), Field('gathered_on', 'datetime'), ) The generated query is: SELECT start.gathered_on, start.mac, end.gathered_on, end.mac FROM record AS end LEFT JOIN record AS start ON (start.mac = end.mac) WHERE ((start.station_id = 11) AND (end.station_id = 12)) ORDER BY EXTRACT(epoch FROM start.gathered_on); and it fails raising the following error: Traceback (most recent call last): File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/paolo/Dropbox/git/web2py/applications/vtraffic/controllers/default.py http://127.0.0.1:8000/admin/default/edit/vtraffic/controllers/default.py, line 655, in module File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in lambda self._caller = lambda f: f() File /home/paolo/Dropbox/git/web2py/applications/vtraffic/controllers/default.py http://127.0.0.1:8000/admin/default/edit/vtraffic/controllers/default.py, line 37, in index left= start.on( (start.mac == end.mac) )) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 8966, in select return adapter.select(self.query,fields,attributes) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1636, in select return self._select_aux(sql,fields,attributes) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1601, in _select_aux self.execute(sql) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1714, in execute return self.log_execute(*a, **b) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1708, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: syntax error at or near end LINE 1: SELECT start.gathered_on, start.mac, end.gathered_on, end.m... What should I have to do? Regards, Paolo --
Re: [web2py] Re: plugin to drag and drop upload of a file
On 01/07/2013 02:39 AM, Alan Etkin wrote: Are the .css files added to the ajax response? In that case, I doubt they will affect the document. I'd add the css files to response.files in the plugin model instead, so they are appended to the app layout. | # models/plugin_file_upload.py response.files.append(...) ... | No they are not. Your solution might work (I'm going to test it). The problem is not that I'm mixing layout and model now... Is it a design problem ? -- Vincenzo Ampolo http://goshawknest.wordpress.com/ http://vincenzo-ampolo.net/ --
Re: [web2py] How do I get last row for each type from table?
Thanks, indeed this was the way. This works great: tb = db.value values = db((tb.gid == 'something')).select(groupby=tb.value, orderby=~tb.updated) On Monday, January 7, 2013 1:28:39 PM UTC+1, viniciusban wrote: Try using groupby clause. On Mon, Jan 7, 2013 at 10:19 AM, Hans Cr clouds...@gmail.comjavascript: wrote: I want my controller to return the last ('updated') row for each 'sid', given a specified 'gid'. 'sid' is multiple times in the table, but I want to have the last row. Can anyone help me? Thanks a lot in advance! Hans db.define_table('value', Field('gid', 'string'), Field('sid', 'string'), Field('value', 'integer', required=True), Field('updated', 'datetime', default=request.now, writable=False, readable=False), format = '%(value)s') -- --
[web2py] registration issue with web2py 2.3.2
After upgrading to 2.3.2, my custom user registration breaks. I have auth_user password encoded as follows in my user's model: ... Field('password', 'password', readable=False, label=T('Password'), requires=[CRYPT(), IS_LENGTH(512, 6)], ), ... During registration, I create the register_form like so in my controller: register_form = SQLFORM.factory( ... db.auth_user.password, Field('password2', 'password', label=T(Verify password'), requires=db.auth_user.password.requires, ), ... ) During form acceptance, the form is validated by this: def validate_registration(form): ... if form.vars.password != form.vars.password2: form.errors.password = form.errors.password2 = T( 'Passwords do not match') ... return form The problem is the passwords aren't the same. I'm assuming the problem is the requires=CRYPT(), which actually encrypts the password twice, producing two different results for password and password2. How would I get CRYPT() to product the same result for both passwords? Do I need to pass in the hmac_key or salt? Or not run CRYPT() at all? --
[web2py] Re: How to parse quoted '%20' RESTfully to web2py?
Isn't the problem that you're using args instead of request.args? I think web2py unquotes stuff for you, but you can always use urllib.unquote if necessary, you don't need the htmlparser it's just a url. Segunda-feira, 7 de Janeiro de 2013 5:04:47 UTC, Alec Taylor escreveu: I can't figure out how to parse url quoted inputs to web2py. Here is my attempt: from HTMLParser import HTMLParserfrom urllib2 import quote, unquote @service.jsondef get_group(): search_for = unquote(HTMLParser.unescape.__func__(HTMLParser, args[0]).encode('ascii', 'ignore')) our_groups_found = db.our_groups(search_for) return dict(our_groups=(our_groups_found or db.our_groups(name=args[0]))) How am I meant to do this? Thanks for all suggestions, Alec Taylor --
[web2py] PosOnlineStore example:, views/default/invioce.html wrongly named. (Fix)
In the PosOnlineStore example appliance, views/default/invioce.html should be called views/default/invoice.h All that's required to fix this is to rename the file to the correct name. This doesn't make much difference to the appearance of the application: instead of an invoice that looks like: Invoice Thank you for your order, this is your invoice code 5b6d0f64-7a1b-451c-9a82-92ae5d054f0c you get Invoice 5b6d0f64-7a1b-451c-9a82-92ae5d054f0c designrequestresponsesessiondb tablesdb stats ajax: False application: POS args: 5b6d0f64-7a1b-451c-9a82-92ae5d054f0c body: cStringIO.StringO object at 0x17a2f80 cid: None client: 127.0.0.1 controller: default cookies: session_id_admin: 127.0.0.1-d5d47669-94d7-4fa7-b157-04606a7e5079comment:domain:expires: httponly:max-age:path:secure:version: session_id_crm: 127.0.0.1-63598a79-d68c-4321-9de3-fc9da7841ff9comment:domain:expires: httponly:max-age:path:secure:version: session_id_junk: 127.0.0.1-1be82b0e-05c5-4852-a2fe-3d17923468dacomment:domain:expires: httponly:max-age:path:secure:version: session_id_pos: 127.0.0.1-92db8e4c-34be-43a6-a1b1-e78b633b49e9comment:domain:expires: httponly:max-age:path:secure:version: session_id_unaltered: 127.0.0.1-2045f204-6a6e-4190-8ade-cec54495661dcomment:domain:expires: httponly:max-age:path:secure:version: session_id_unlatered: 127.0.0.1-beacb73d-d1e8-4a0d-898a-96bad8858725comment:domain:expires: httponly:max-age:path:secure:version: session_id_web2pynotes: 127.0.0.1-51f1a85a-5f66-49ff-b559-673d3d90f3c9comment:domain:expires: httponly:max-age:path:secure:version: session_id_welcome: 127.0.0.1-b0b3b9b9-852e-48d6-bd67-49f9b38faa6dcomment:domain:expires: httponly:max-age:path:secure:version: env: app_folders: set(['/u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py/applications/crm/', '/u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py/applications/examples/', '/u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py/applications/POS/', '/u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py/applications/welcome/', '/u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py/applications/admin/']) applications_parent: /u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py cmd_args: cmd_options: Values at 0x179f518: {'verbose': False, 'ip': '127.0.0.1', 'with_scheduler': False, 'ips': [], 'shutdown_timeout': 5, 'taskbar': False, 'port': 8000, 'maxthreads': None, 'softcron': False, 'server_name': 'pluto', 'bpython': False, 'nogui': False, 'pid_filename': 'httpserver.pid', 'extcron': False, 'runcron': False, 'run_system_tests': False, 'test': None, 'folder': '/u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py', 'config': '', 'minthreads': None, 'winservice': '', 'shell': None, 'run': '', 'log_filename': 'httpserver.log', 'debuglevel': 30, 'args': [''], 'socket_timeout': 5, 'ssl_ca_certificate': None, 'scheduler': None, 'profiler_filename': None, 'ssl_private_key': '', 'scheduler_groups': None, 'password': 'ask', 'request_queue_size': 5, 'ssl_certificate': '', 'cronjob': False, 'numthreads': None, 'quiet': False, 'interfaces': None, 'import_models': False, 'timeout': 10, 'plain': False, 'nobanner': False} db_sessions: set([]) debugging: False gluon_parent: /u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py http_accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 http_accept_charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 http_accept_encoding: gzip,deflate http_accept_language: en-gb,en;q=0.5 http_cache_control: no-cache http_connection: keep-alive http_cookie: session_id_welcome=127.0.0.1-b0b3b9b9-852e-48d6-bd67-49f9b38faa6d; session_id_admin=127.0.0.1-d5d47669-94d7-4fa7-b157-04606a7e5079; session_id_web2pynotes=127.0.0.1-51f1a85a-5f66-49ff-b559-673d3d90f3c9; session_id_crm=127.0.0.1-63598a79-d68c-4321-9de3-fc9da7841ff9; session_id_unlatered=127.0.0.1-beacb73d-d1e8-4a0d-898a-96bad8858725; session_id_unaltered=127.0.0.1-2045f204-6a6e-4190-8ade-cec54495661d; session_id_junk=127.0.0.1-1be82b0e-05c5-4852-a2fe-3d17923468da; session_id_pos=127.0.0.1-92db8e4c-34be-43a6-a1b1-e78b633b49e9 http_host: 127.0.0.1:8000 http_keep_alive: 115 http_pragma: no-cache http_referer: http://127.0.0.1:8000/POS/default/buy http_user_agent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13 is_jython: False is_pypy: False local_hosts: pluto.uit.co.uk :::127.0.0.1 ::1 pluto 127.0.1.1 127.0.0.1 path_info: /POS/default/invoice/5b6d0f64-7a1b-451c-9a82-92ae5d054f0c query_string:remote_addr: 127.0.0.1 remote_port: 38824 request_method: GET request_uri: /POS/default/invoice/5b6d0f64-7a1b-451c-9a82-92ae5d054f0c script_name:server_name: pluto server_port: 8000 server_protocol: HTTP/1.1 server_software: Rocket 1.2.6 web2py_path: /u/r/w/web2py.com/www.web2py.com/examples/static/junk/web2py web2py_version: 2 3 2 datetime.datetime(2012, 12, 17, 15, 3, 30) stable wsgi_errors: open file 'stderr', mode 'w' at
Re: [web2py] Re: plugin to drag and drop upload of a file
I don't see it as an issue, but I'd consider merging those css files into one, to reduce the amount of requests that need to be made. The fact that they are CSS files and not hard-coded means that you aren't mixing them up, since they are still separate. On Monday, January 7, 2013 6:23:22 AM UTC-7, Vincenzo Ampolo wrote: The problem is not that I'm mixing layout and model now... Is it a design problem ? -- Vincenzo Ampolohttp://goshawknest.wordpress.com/http://vincenzo-ampolo.net/ --
Re: [web2py] Changed date to datetime. Now I get: invalid literal for int() with base 10:
I cleared all files from the applications/databases directory to let it start new. That includes all .table files and storage.sqlite. What I did was: Changed date to datetime Shut down server rm applications/databases/* Start server Load app and leave a comment Reload comments page Somehow the error still persists. I thought for sure it had to be something in my code but I've checked and triple checked it. On Monday, January 7, 2013 3:14:30 AM UTC-8, Massimo Di Pierro wrote: When you delete a sqlite database, make sure you delete all the associated .table files too. On Sunday, 6 January 2013 20:45:34 UTC-6, HittingSmoke wrote: Yep, SQLITE. But I completely wiped the database from the disk in web2py/applications/application/databases and let web2py write a completely new one. Wouldn't I not need to alter anything if web2py has created a fresh database with the proper field types? On Sunday, January 6, 2013 6:37:48 PM UTC-8, rochacbruno wrote: Are you using SQLITE? SQLITE does not support alter table for changing column types. SO you have to use sqliteman program to alter directly on sqlite. --
Re: [web2py] Re: How to parse quoted '%20' RESTfully to web2py?
Oh oops, reduced my stuff to a test-case and forgot to fill in the rest of my definition. Meant to be `def get_group(*args, **kwargs)` On Tue, Jan 8, 2013 at 3:12 AM, Leonel Câmara leonelcam...@gmail.comwrote: Isn't the problem that you're using args instead of request.args? I think web2py unquotes stuff for you, but you can always use urllib.unquote if necessary, you don't need the htmlparser it's just a url. Segunda-feira, 7 de Janeiro de 2013 5:04:47 UTC, Alec Taylor escreveu: I can't figure out how to parse url quoted inputs to web2py. Here is my attempt: from HTMLParser import HTMLParserfrom urllib2 import quote, unquote @service.jsondef get_group(): search_for = unquote(HTMLParser.unescape.__**func__(HTMLParser, args[0]).encode('ascii', 'ignore')) our_groups_found = db.our_groups(search_for) return dict(our_groups=(our_groups_**found or db.our_groups(name=args[0]))) How am I meant to do this? Thanks for all suggestions, Alec Taylor -- --
Re: [web2py] Re: How to parse quoted '%20' RESTfully to web2py?
On Tue, Jan 8, 2013 at 4:25 AM, Alec Taylor alec.tayl...@gmail.com wrote: Oh oops, reduced my stuff to a test-case and forgot to fill in the rest of my definition. Meant to be `def get_group(*args, **kwargs)` [have it in a @request.restful()) On Tue, Jan 8, 2013 at 3:12 AM, Leonel Câmara leonelcam...@gmail.comwrote: Isn't the problem that you're using args instead of request.args? I think web2py unquotes stuff for you, but you can always use urllib.unquote if necessary, you don't need the htmlparser it's just a url. Segunda-feira, 7 de Janeiro de 2013 5:04:47 UTC, Alec Taylor escreveu: I can't figure out how to parse url quoted inputs to web2py. Here is my attempt: from HTMLParser import HTMLParserfrom urllib2 import quote, unquote @service.jsondef get_group(): search_for = unquote(HTMLParser.unescape.__**func__(HTMLParser, args[0]).encode('ascii', 'ignore')) our_groups_found = db.our_groups(search_for) return dict(our_groups=(our_groups_**found or db.our_groups(name=args[0]))) How am I meant to do this? Thanks for all suggestions, Alec Taylor -- --
[web2py] Help integrating s-cubism uploadify widget
Hi I am having problems integrating this plugin http://dev.s-cubism.com/plugin_uploadify_widget in to my form. In my Models.py I have from plugin_uploadify_widget import ( uploadify_widget, IS_UPLOADIFY_IMAGE, IS_UPLOADIFY_FILENAME, IS_UPLOADIFY_LENGTH ) db.define_table('video', Field('userinfo', db.auth_user, default=auth.user_id, readable=False, writable=False), Field('title', length=64, requires = IS_NOT_EMPTY()), Field('trailer', 'upload', IS_LENGTH(550*1024*1024, error_message='filesize exceeds 550 megabytes'), autodelete=True), Field('video', 'upload', IS_LENGTH(550*1024*1024, error_message='filesize exceeds 550 megabytes'), autodelete=True), Field('created_on','datetime',default=datetime.datetime.today(), writable=False,readable=False)) The core ## # Inject the uploadify widget # The requires needs custom validators. db.video.trailer.widget = uploadify_widget db.video.trailer.requires = IS_EMPTY_OR(IS_UPLOADIFY_LENGTH(3012024)) # Inject the another uploadify widget with different requires db.video.video.widget = uploadify_widget db.video.video.requires = IS_UPLOADIFY_LENGTH(3012240, 1) But I am not sure what to do from here. How do I get the plugin to replace the regular form area for uploads. My controller consists of this @auth.requires_membership('admin') def video(): videos = db(db.video.id0).select() form = SQLFORM(db.video) if form.accepts(request,session): response.flash = 'You have successfully created a new video' return dict(form=form,videos=videos) elif form.errors: response.flash = 'Please correct the highlighted fields' return dict(form=form,videos=videos) #form = LOAD('plugin_uploadify_widget', args='ajax', ajax=True) return dict(form=form,videos=videos) Any ideas? *cheers and thank you for any help --
[web2py] Re: self join on postgres
Hi Niphlod, yes it solved the problem. Now I have an other problem, I need to make a self left join, but limited to 1 match only. Namely, I've just need to make the join only for the first matching row. I've tried something like: rows = db( query ).select(start.gathered_on,start.mac,start.id, end.gathered_on, end.mac, end.id, start.gathered_on.epoch(), end.gathered_on.epoch(), orderby=start.gathered_on.epoch(), left= start.on(start.mac == end.mac), groupby=start.id, cacheable = True) This actually works on sqlite but on postgres failed because on postgres you can group only onto the field expressed in the select. Moreover, even if on sqlite it works, It select the wrong rows. Online I have found this post: http://archives.postgresql.org/pgsql-novice/2011-01/msg00069.php and now I am trying to understand how to define a sub_select with the limitby=1 to carry out the left join. Any idea ? Regards, Paolo On Monday, January 7, 2013 2:21:33 PM UTC+1, Niphlod wrote: did you try changing start and end as aliases ? while start on postgresql isn't reserved ( but is a reserved keyword for t-sql:2003 and t-sql:1999), end is reserved even for postgresql. On Monday, January 7, 2013 1:21:27 PM UTC+1, Paolo valleri wrote: Hi all, I've problems on defining self join queries on postgres, the query, works on sqlite, is defined as follows: start = db.record.with_alias('start') end = db.record.with_alias('end') query = ((start.station_id == 11) (end.station_id == 12)) rows = db( query ).select(start.gathered_on,start.mac, end.gathered_on, end.mac, orderby=start.gathered_on.epoch(), left= start.on( (start.mac == end.mac) )) The table is: db.define_table('record', Field('station_id', 'reference station'), Field('log_id', 'reference log'), Field('mac'), Field('gathered_on', 'datetime'), ) The generated query is: SELECT start.gathered_on, start.mac, end.gathered_on, end.mac FROM record AS end LEFT JOIN record AS start ON (start.mac = end.mac) WHERE ((start.station_id = 11) AND (end.station_id = 12)) ORDER BY EXTRACT(epoch FROM start.gathered_on); and it fails raising the following error: Traceback (most recent call last): File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/paolo/Dropbox/git/web2py/applications/vtraffic/controllers/default.py http://127.0.0.1:8000/admin/default/edit/vtraffic/controllers/default.py, line 655, in module File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in lambda self._caller = lambda f: f() File /home/paolo/Dropbox/git/web2py/applications/vtraffic/controllers/default.py http://127.0.0.1:8000/admin/default/edit/vtraffic/controllers/default.py, line 37, in index left= start.on( (start.mac == end.mac) )) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 8966, in select return adapter.select(self.query,fields,attributes) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1636, in select return self._select_aux(sql,fields,attributes) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1601, in _select_aux self.execute(sql) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1714, in execute return self.log_execute(*a, **b) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1708, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: syntax error at or near end LINE 1: SELECT start.gathered_on, start.mac, end.gathered_on, end.m... What should I have to do? Regards, Paolo --
[web2py] Is it possible to define how a field is rendered in the DB model?
For instance, could I set a field in the database to be always rendered in Markmin or sanitized HTML instead of in the view every time it's queried? --
[web2py] Re: web2py and crawlers
is it possible to use scrapy http://scrapy.org/? On Monday, January 7, 2013 2:20:16 PM UTC+3, sasogeek wrote: the app is on an online server... http://sasogeek.pythonanywhere.com/newup/ will that still work? On Monday, 7 January 2013 11:15:51 UTC, Massimo Di Pierro wrote: You can try: python web2py.py -S yourapp -M -R yourscript.py use -h for command line options On Monday, 7 January 2013 04:25:13 UTC-6, sasogeek wrote: i was wondering, if i wrote a crawler in models to populate a database table, how would the crawler run? as in how to run that script? --
[web2py] Re: Is it possible to define how a field is rendered in the DB model?
using field.represent or the new filter_out parameter ... docs aren't there but it's pretty simple. db.define_table('test3', Field('testfield', filter_out=lambda value : value.upper) ) However, for computations like MARKMIN, the better choice is to store in another computed field the result, so you don't spend cpu cycles on rendering over and over the same thing every time. On Monday, January 7, 2013 8:53:43 PM UTC+1, HittingSmoke wrote: For instance, could I set a field in the database to be always rendered in Markmin or sanitized HTML instead of in the view every time it's queried? --
[web2py] Associate a db record with a logged in user
This seems so elementary, but I can't seem to find out how to do it in the book or googling the group ... I have several users defined and when that user is logged in and is creating a db record that is specific to that user, I want it to be automatically assigned to him/her. For example, given a model that defines a checking account, db.define_table('account', Field('type'), Field('balance'), Field('user', db.auth_user)) How can I use the crud.create forms to automatically assign the value of the user field on the account model to the currently logged in user? Thanks, Dave --
[web2py] Re: self join on postgres
If I understand correctly the problem it's a matter of using windowing functions, that are not available on all db engines and far too complicated to expose a consistent api by the DAL. Picking out the first match only doesn't quite explain what you need in detail (maybe it can be worked out without windowing functions in a particular case) can you please make an example of real data to start with and what you want the resultset to return ? On Monday, January 7, 2013 7:46:17 PM UTC+1, Paolo valleri wrote: Hi Niphlod, yes it solved the problem. Now I have an other problem, I need to make a self left join, but limited to 1 match only. Namely, I've just need to make the join only for the first matching row. I've tried something like: rows = db( query ).select(start.gathered_on,start.mac,start.id, end.gathered_on, end.mac, end.id, start.gathered_on.epoch(), end.gathered_on.epoch(), orderby=start.gathered_on.epoch(), left= start.on(start.mac == end.mac), groupby=start.id, cacheable = True) This actually works on sqlite but on postgres failed because on postgres you can group only onto the field expressed in the select. Moreover, even if on sqlite it works, It select the wrong rows. Online I have found this post: http://archives.postgresql.org/pgsql-novice/2011-01/msg00069.php and now I am trying to understand how to define a sub_select with the limitby=1 to carry out the left join. Any idea ? Regards, Paolo On Monday, January 7, 2013 2:21:33 PM UTC+1, Niphlod wrote: did you try changing start and end as aliases ? while start on postgresql isn't reserved ( but is a reserved keyword for t-sql:2003 and t-sql:1999), end is reserved even for postgresql. On Monday, January 7, 2013 1:21:27 PM UTC+1, Paolo valleri wrote: Hi all, I've problems on defining self join queries on postgres, the query, works on sqlite, is defined as follows: start = db.record.with_alias('start') end = db.record.with_alias('end') query = ((start.station_id == 11) (end.station_id == 12)) rows = db( query ).select(start.gathered_on,start.mac, end.gathered_on, end.mac, orderby=start.gathered_on.epoch(), left= start.on( (start.mac == end.mac) )) The table is: db.define_table('record', Field('station_id', 'reference station'), Field('log_id', 'reference log'), Field('mac'), Field('gathered_on', 'datetime'), ) The generated query is: SELECT start.gathered_on, start.mac, end.gathered_on, end.mac FROM record AS end LEFT JOIN record AS start ON (start.mac = end.mac) WHERE ((start.station_id = 11) AND (end.station_id = 12)) ORDER BY EXTRACT(epoch FROM start.gathered_on); and it fails raising the following error: Traceback (most recent call last): File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/paolo/Dropbox/git/web2py/applications/vtraffic/controllers/default.py http://127.0.0.1:8000/admin/default/edit/vtraffic/controllers/default.py, line 655, in module File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in lambda self._caller = lambda f: f() File /home/paolo/Dropbox/git/web2py/applications/vtraffic/controllers/default.py http://127.0.0.1:8000/admin/default/edit/vtraffic/controllers/default.py, line 37, in index left= start.on( (start.mac == end.mac) )) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 8966, in select return adapter.select(self.query,fields,attributes) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1636, in select return self._select_aux(sql,fields,attributes) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1601, in _select_aux self.execute(sql) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1714, in execute return self.log_execute(*a, **b) File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1708, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: syntax error at or near end LINE 1: SELECT start.gathered_on, start.mac, end.gathered_on, end.m... What should I have to do? Regards, Paolo --
[web2py] Re: Is it possible to define how a field is rendered in the DB model?
Hi! What is a difference between represent and filter_out? Tnx. --
Re: [web2py] Changed date to datetime. Now I get: invalid literal for int() with base 10:
I understand all the steps involved and usually the operations you carried on lead to a database recreationbut there's a problem somewhere. If you deleted the sqlite database it *can't* complain about any data in it (leaving aside for one moment the format the data is in the field)... This error type 'exceptions.ValueError' invalid literal for int() with base 10: '06 21:12:04' if returned by a select means that: - there is a database - there is a table - there is a column - there is a row filled with some value So either you have deleted correctly the database and your app commits something or you didn't delete the database at all On Monday, January 7, 2013 6:16:48 PM UTC+1, HittingSmoke wrote: I cleared all files from the applications/databases directory to let it start new. That includes all .table files and storage.sqlite. What I did was: Changed date to datetime Shut down server rm web2py/applications/application/databases/* Start server Load app and leave a comment Reload comments page Somehow the error still persists. I thought for sure it had to be something in my code but I've checked and triple checked it. On Monday, January 7, 2013 3:14:30 AM UTC-8, Massimo Di Pierro wrote: When you delete a sqlite database, make sure you delete all the associated .table files too. On Sunday, 6 January 2013 20:45:34 UTC-6, HittingSmoke wrote: Yep, SQLITE. But I completely wiped the database from the disk in web2py/applications/application/databases and let web2py write a completely new one. Wouldn't I not need to alter anything if web2py has created a fresh database with the proper field types? On Sunday, January 6, 2013 6:37:48 PM UTC-8, rochacbruno wrote: Are you using SQLITE? SQLITE does not support alter table for changing column types. SO you have to use sqliteman program to alter directly on sqlite. --
[web2py] Re: Associate a db record with a logged in user
Field('user_id', 'reference auth_user', default=auth.user_id) On Monday, January 7, 2013 9:31:33 PM UTC+1, Dave Cenker wrote: This seems so elementary, but I can't seem to find out how to do it in the book or googling the group ... I have several users defined and when that user is logged in and is creating a db record that is specific to that user, I want it to be automatically assigned to him/her. For example, given a model that defines a checking account, db.define_table('account', Field('type'), Field('balance'), Field('user', db.auth_user)) How can I use the crud.create forms to automatically assign the value of the user field on the account model to the currently logged in user? Thanks, Dave --
[web2py] Re: Is it possible to define how a field is rendered in the DB model?
Thanks. Concerning saving the computed result, would that be another field which saves the post in HTML and using that field when rendering pages? I wouldn't think rendering markmin to HTML would be of an consequence on CPU load. I think the complication involved in storing the same data in two formats in the database as well as the database size would be something I'd want to avoid. On Monday, January 7, 2013 12:28:55 PM UTC-8, Niphlod wrote: using field.represent or the new filter_out parameter ... docs aren't there but it's pretty simple. db.define_table('test3', Field('testfield', filter_out=lambda value : value.upper) ) However, for computations like MARKMIN, the better choice is to store in another computed field the result, so you don't spend cpu cycles on rendering over and over the same thing every time. On Monday, January 7, 2013 8:53:43 PM UTC+1, HittingSmoke wrote: For instance, could I set a field in the database to be always rendered in Markmin or sanitized HTML instead of in the view every time it's queried? --
[web2py] Re: Is it possible to define how a field is rendered in the DB model?
represent only affects how the value is displayed in forms (including read-only forms) and the grid, whereas filter_out is applied when the database result is parsed into the Rows object, so it affects everywhere the value might be used or displayed. represent is often used with reference fields, which typically makes more sense than using filter_out because although you may want to display the reference field differently, you probably still want to retain the original id value as well (filter_out replaces the original value with the transformed value). Anthony On Monday, January 7, 2013 3:35:09 PM UTC-5, szimszon wrote: Hi! What is a difference between represent and filter_out? Tnx. --
[web2py] Delete a user
What's the correct way of deleting a user? Say someone creates an account on my page and wants to remove him/herself. How can I do this? Thank you! --
Re: [web2py] Delete a user
If you have shell access. Go to your shell python web2py.py -S yourappname -M db(db.auth_user.email==some...@domain.com).delete() db.commit() The user with some...@domain.com is now deleted! If you dont hace shell access, just go to your admi interface, database adminitration and delete from auth_user table. --
Re: [web2py] Delete a user
Well, I know I can do this from the admin interface but I was wondering how a user can remove himself from the website if he so wishes. Should I put the code `db(db.auth_user.email==some...@domain.com).delete()` in a {{=A(_href=action)}} or is that bad practice? I want the user to be able to delete himself. On Mon, Jan 7, 2013 at 9:56 PM, Bruno Rocha rochacbr...@gmail.com wrote: If you have shell access. Go to your shell python web2py.py -S yourappname -M db(db.auth_user.email==some...@domain.com).delete() db.commit() The user with some...@domain.com is now deleted! If you dont hace shell access, just go to your admi interface, database adminitration and delete from auth_user table. -- --
[web2py] Re: Is it possible to define how a field is rendered in the DB model?
it's completely up to you. Try to do some tests though. Unless you're storing millions of markmin fragments, having a row holding 0,2 KB of markmin source or 0,2+0,4 of markmin source + html at the end of the day means adding few megs up. On the other end, a reddited blog post having to render the markmin to 1M users may speed down your app a bit. On the far end, caching the html of the page in ram or in memcache or in redis in the controller will be the best possible solution but again, it depends on the app. On Monday, January 7, 2013 9:51:36 PM UTC+1, HittingSmoke wrote: Thanks. Concerning saving the computed result, would that be another field which saves the post in HTML and using that field when rendering pages? I wouldn't think rendering markmin to HTML would be of an consequence on CPU load. I think the complication involved in storing the same data in two formats in the database as well as the database size would be something I'd want to avoid. On Monday, January 7, 2013 12:28:55 PM UTC-8, Niphlod wrote: using field.represent or the new filter_out parameter ... docs aren't there but it's pretty simple. db.define_table('test3', Field('testfield', filter_out=lambda value : value.upper) ) However, for computations like MARKMIN, the better choice is to store in another computed field the result, so you don't spend cpu cycles on rendering over and over the same thing every time. On Monday, January 7, 2013 8:53:43 PM UTC+1, HittingSmoke wrote: For instance, could I set a field in the database to be always rendered in Markmin or sanitized HTML instead of in the view every time it's queried? --
Re: [web2py] Delete a user
You can do it, but also consider what should happen to referenced records - be aware of any cascading deletes. On Monday, January 7, 2013 10:00:48 PM UTC, Daniele wrote: Well, I know I can do this from the admin interface but I was wondering how a user can remove himself from the website if he so wishes. Should I put the code `db(db.auth_user.email==some...@domain.comjavascript:).delete()` in a {{=A(_href=action)}} or is that bad practice? I want the user to be able to delete himself. On Mon, Jan 7, 2013 at 9:56 PM, Bruno Rocha rocha...@gmail.comjavascript: wrote: If you have shell access. Go to your shell python web2py.py -S yourappname -M db(db.auth_user.email==some...@domain.com javascript:).delete() db.commit() The user with som...@domain.com javascript: is now deleted! If you dont hace shell access, just go to your admi interface, database adminitration and delete from auth_user table. -- --
[web2py] Re: self join on postgres
after a full day at work I may lack the usual fantasy, but what you're trying to do can't be even achieved by a relatively simple windowed function What you're trying to do is recursing. way out of DAL reach (if you want to do it in a single query) Trying to explain better Real data helps. For every station_id record with the same mac address you want to find the min gathered_on record from the same table (with another station_id) and subtract it for every next possible match. One thing is requiring 2013-01-21 11:23:35;a;127167;2013-01-21 11:23:45;a;127168 2013-01-21 11:23:00;a;127169;2013-01-21 11:23:45;a;127168 That can be accomplished by something like this select * from ( selectstart_point.gathered_on,start_point.mac,start_point.id, end_point.gathered_on,end_point.mac,end_point.id, row_number() over (partition by start_point.id order by end_point. gathered_on) as filter_field from record as start_point inner join record as end_point on start_point.mac = end_point.mac and start_point.gathered_on = end_point.gathered_on where start_point.station_id = 13 and end_point.station_id = 14 ) as q where q.filter_field = 1 because for the record 127167 the next record with another station_id is 127168, but then for the 127169 you don't want the 127168, you want 127170 because 127168 has been booked before by 127169. Honestly, (beware of the lack of fantasy :P) I'd do a loop in python instead of using recursing in the db itself unless you have zillions of windows (i.e. you have 1000 station_id = 13 and 1000 station_id = 14, and 1000 distinct station_id), just because it's more readable than what it would be needed in raw sql --
[web2py] Re: cpdb errors
Thanks Mart, That's sort of fixed it, but starting to get additional issues with the auth tables. https://lh4.googleusercontent.com/-HAmuqaTtnd0/UOtg3XU7NHI/AG8/LpeAt3Dm15w/s1600/copy+database2.png Think have seen this before with csv imports and have gotten around by deleting suspect areas from the import source files. (obviously not really an option here, and now wondering if that hack is causing a postgres memory leak on import) --
[web2py] Re: tab separated csv file
I think the import button should have a delimiter field makes things easier. On Thursday, 12 March 2009 00:08:27 UTC+8, mdipierro wrote: There is no configuration parameter to do so. You mat create your own csv serializer. look into the python csv module. On Mar 11, 10:01 am, Marco Prosperi marcoprosperi...@gmail.com wrote: hello everybody, how can I change the following function (defined in appadmin.py controller) so that the downloaded file has tab separated values instead of comma separated? Or do I have to change some settings somewhere? thanks in advance, Marco def csv(): import gluon.contenttype response.headers['Content-Type'] = \ gluon.contenttype.contenttype('.csv') db = get_database(request) query = get_query(request) if not query: return None response.headers['Content-disposition'] = \ 'attachment; filename=%s_%s.csv'\ % tuple(request.vars.query.split('.')[:2]) return str(db(query).select()) --
[web2py] Re: cpdb errors
Hi Simon, Yes, that looks like a CSV error message. Possibly, the CSV format is missing something expected... I would say that the problem occurs when converting from CSV. I would suggest that you take a look at Massimo's CSVStudio @https://code.google.com/p/csvstudio/ i think it has something that will convert your CSV cols and rows to a model by generating db.define_table(...) Never the less, I will keep looking and see what turns up. I ran these on either a Linux flavour or MacOS... Unfortunately, I wasn't able to find a usable windows box today. I didn't run this against entire web2py filesets, I simply pointed to a location on my laptop, dumped different versions of dal.py there replacing them with what ever version I found - some old some more recent)... But they all worked. I hope this helps, Mart :) On Monday, January 7, 2013 4:05:40 PM UTC-8, Simon Ashley wrote: Thanks Mart, That's sort of fixed it, but starting to get additional issues with the auth tables. https://lh4.googleusercontent.com/-HAmuqaTtnd0/UOtg3XU7NHI/AG8/LpeAt3Dm15w/s1600/copy+database2.png Think have seen this before with csv imports and have gotten around by deleting suspect areas from the import source files. (obviously not really an option here, and now wondering if that hack is causing a postgres memory leak on import) ps. what OS and web2py version are you using? (source 2.3.2 here) --
[web2py] Re: anyone tried jQuery svg?
I haven't either, but I'd recommend a look at d3js.org, if you want to use svg. I've done something similar to this one, using a web2py generated json data feed - data driven layout ! http://mbostock.github.com/d3/talk/2016/bundle.html On Monday, January 7, 2013 7:29:10 AM UTC+13, villas wrote: Look at what he does here: http://keith-wood.name/svgBasics.html See the drawInitial function. You need to load it, put it into a document.ready function or something. On Sunday, January 6, 2013 2:14:13 PM UTC, jonas wrote: Hi. Has anyone here tried the jQuery svg lib http://keith-wood.name/svg.html ? I tried to use it in web2py but with no success. the necessary lib was imported: script src={{=URL('static','js/jquery/jquery.svg.js')}}/script but is seems that the svg function is not present : div class=testsvg should be here/div script $('.test').svg(); var svg=$('.test').svg('get'); svg.circle(130, 75, 50, {fill: 'none', stroke: 'red', strokeWidth: 3}); /script the above snippet doesn't work. anyone tried this? --
[web2py] rocket can not send email on windows, starttls extension not supported by server
web2py 2.7.3 on windows, rocket server. I want to setup email for lost passwords and registration. I don't need authentication. I can send email from python (following the example in the 2.7.3 documentation 18.1.1) I've followed the book closely and have the mail server like so: mail=auth.settings.mailer mail.settings.server = 'smtp.bigair.com.au:25' mail.settings.sender = 'accou...@vci.com.au' mail.settings.login = None in the console I see this error WARNING:web2py:Mail.send failure:STARTTLS extension not supported by server. any ideas? --
Re: [web2py] Jquery Kit
Thank you for the link, Bruno! On Mon, Jan 7, 2013 at 9:36 PM, Bruno Rocha rochacbr...@gmail.com wrote: An interesting set of Jquery plugins.. http://jquery-jkit.com/ Bruno -- --
[web2py] Re: cpdb errors
Thanks Mart, That gives me some clues and a renewed focus. Issue may be with postgres (at least the install I had - has been deleted and will be installed). Will also try ubuntu environment. Will report back ... --
[web2py] Re: rocket can not send email on windows, starttls extension not supported by server
This open source thing could really take off. mail.settings.tls = False does the job --
[web2py] Re: subforms / formsets / form cloning imprementation
i have an (untested) idea...plugging together a few things i have used before - you could create templates of field sets using handlebars: http://handlebarsjs.com/ then you can via JS add them to the page based on user interaction. - you can use hidden fields to provide some meta data on the form. - remembering that in your controller you define your SQLFORM *before* you process it, you could check for the presence of your hidden fields in request.vars, and based on their values initialize your SQLFORM to match the sub-forms that were added to the form. then when you call .process it will check all those fields as well. i don't know if that is a great idea or not (we recently solved this problem at my workplace but i think ended up using handlebars and manual form processing)it's a thought we considered and still might try! christian On Sunday, January 6, 2013 11:02:01 PM UTC-8, Henrique Pantarotto wrote: Hello everybody! I'm quite new to Python and web2py, but I consumed all of web2py's wonderful documentation at the last few days and I'm quite amazed at this wonderful framework. But there's a feature that I need that I couldn't find a way to easily implement it. The application that I'm developing requires extensive use of form cloning within a single web page, done dynamically at the client side. I'm not really sure how to call this technique, so I found a bit hard to find information regarding this at this mailing list's archive. What I want to accomplish can be easily understood viewing the screenshots from this tool: http://www.mdelrosso.com/sheepit/ I already have my own (ugly) jquery code to create the forms dynamically, and of course I could validate it manually on web2py's side, but I was looking into an easier implementation using something like FORM or SQLFORM. Like I said, I'm very new to web2py and python, and I have no idea how django works, but I think I need to accomplish something similar to this: https://docs.djangoproject.com/en/dev/topics/forms/formsets/ I tried searching this mailing list archive and I found a couple of discussions from people trying to do the same thing, but I didn't find a solution. https://groups.google.com/forum/#!topic/web2py/ssaSj6v9Wu8/discussion https://groups.google.com/d/topic/web2py/UK8NZ1VMlNk/discussion But these are threads from 2011 There's also this guy asking something similar a couple of months ago: https://groups.google.com/d/topic/web2py/IPMz4FylT2k/discussion and http://stackoverflow.com/questions/13215902/web2py-possible-to-submit-multiple-forms-with-a-single-submit-button/13215926#13215926but the solution presented didn't seem very elegant. Anyway, I would really appreciate any help on this. Thanks, Henrique. --
[web2py] Re: Bar encoded text fields
shouldn't non-list data types not accept list input? this sounds like an un-expected side effect to me. On Sunday, January 6, 2013 3:25:33 PM UTC-8, Massimo Di Pierro wrote: This is correct in the sense that since you try to store a list, web2py thinks it is a 'list:string' type of object and escapes the list accordingly accordingly. At the same time, the behavior in this case is not really specified and could be changed. On Sunday, 6 January 2013 14:52:51 UTC-6, Alan Etkin wrote: db.define_table(mytable, Field(mytext, text)) Table mytable (id,mytext) db.mytable.insert(mytext=(1,2,3,4)) 1L db.mytable[1].mytext '|1|2|3|4|' print db.mytable[1].mytext |1|2|3|4| I am trying to implement native support for json data type in dal (for databases like mongodb) and found this behavior Is this correct? I'd expect any non string object passed to .insert/.update for text fields to be converted to database string type (the one specified for the adapter), not a bar encoded string. Also, the default widget is completed with the bar encoded value. I think that some fields like text (anything but list:type in fact) should not bar encode input. My version is web2py Version 2.4.1-alpha.2+timestamp.2013.01.06.09.27.15 --
[web2py] Re: registration issue with web2py 2.3.2 [CLOSED]
Alright, I think I got this figured out. Issue is 2-fold. First, IS_LENGTH validator is executed after CRYPT() runs, so it fails. Moving IS_LENGTH to the array position before CRYPT() and changing password2 validator to ... requires=IS_EQUAL_TO(request.vars.password) ... causes things to work. On Monday, January 7, 2013 10:47:47 PM UTC+8, weheh wrote: After upgrading to 2.3.2, my custom user registration breaks. I have auth_user password encoded as follows in my user's model: ... Field('password', 'password', readable=False, label=T('Password'), requires=[CRYPT(), IS_LENGTH(512, 6)], ), ... During registration, I create the register_form like so in my controller: register_form = SQLFORM.factory( ... db.auth_user.password, Field('password2', 'password', label=T(Verify password'), requires=db.auth_user.password.requires, ), ... ) During form acceptance, the form is validated by this: def validate_registration(form): ... if form.vars.password != form.vars.password2: form.errors.password = form.errors.password2 = T( 'Passwords do not match') ... return form The problem is the passwords aren't the same. I'm assuming the problem is the requires=CRYPT(), which actually encrypts the password twice, producing two different results for password and password2. How would I get CRYPT() to product the same result for both passwords? Do I need to pass in the hmac_key or salt? Or not run CRYPT() at all? --