[web2py] db._adapter.reconnect()
In the past, the database adapter disconnected when a constraint on the database side prohibited a transaction to complete. Will these changes make it possible to handle such a situation as an exception? I am working with Postresql. Regards Johann
[web2py] Re: Default table schema for the Auth tables
cyan cyanasch...@gmail.com wrote: definitions for each of them, if possible. In addition, can we remove fields from these tables? I know we can add extra fields or re-define the I removed the name fields from auth_user and then some navbar function wrote Hello None,. OK, some minor problem. But you can't know which fields are used at the moment without searching the complete source yourself. And the next update could require the existence of a field (see this navbar function, which wasn't used in earlier versions of the packaged views). web2py's auth is take it or leave it. PS: Please don't hang yourself up on my example. I said minor problem.
Re: [web2py] Re: bidirectional languages
On Thu, Apr 12, 2012 at 11:39 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You have to use something like in CSS .rlt { direction:rtl; } .ltr { direction:ltr; } and use something like span class={{=T('rtl')}}{{=T('text')}}/span and translate the direction as you translate the text. I didn't clearly get you, need some more clarification. Do you mind to have a chat. I have already sent you an invitation via gtalk. Or else if you are in skype or irc that would also be fine. Thanks in advance. On Thursday, 12 April 2012 08:22:09 UTC-5, Kalpa Welivitigoda wrote: On Thu, Apr 12, 2012 at 5:56 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Yes. You have to translate the CSS that determines the alignment as well. My translation file is applications/eden/languages/ur.py (eden is my application name). There I have an untranslated string as Today (Monday) and in Urdu language which is a RTL it is displayed as Today ((Monday. I want to have the ( and ) in LTR and the rest in RTL. How can I accomplish this? On Thursday, 12 April 2012 05:15:29 UTC-5, Kalpa Welivitigoda wrote: Hi, Does the translation feature of web2py support bidirectional languages? -- Best Regards, Kalpa Pathum Welivitigoda http://about.me/callkalpa -- Best Regards, Kalpa Pathum Welivitigoda http://about.me/callkalpa
Re: [web2py] heroku, web2py and gunicorn
Hi Massimo, I am trying to explore gunicorn. Below is the command I use to activate my site. I am not sure if the parameter -s gunicorn does anything. How do I confirm this? I have gunicorn, eventlet and greenlet installed via virtualenv. I am trying to streamline my deployment and eventually remove the port number as well. * -bash-3.2$* python web2py.py -a'recycle' -i flockbird.com -p 9065 -s gunicorn Thanks, sincerely, Rahul D [www.flockbird.com] On Friday, July 22, 2011 9:33:10 PM UTC+5:30, Furqan Rauf wrote: I could do it but I am a newbie, no nothing about the deployment or stress testing On Fri, Jul 22, 2011 at 10:06 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Hello everybody, heroku will be supporting web2py. They run gunicorn. web2py runs with gunicorn but I have never tried it. Any volunteer to run some stress tests? cd web2py python anyserver -s gunicorn Massimo -- *-Furqan Rauf* *Do you love your creator? Love your fellow-beings first. -Prophet Muhammad * *http://www.amway.com/furqanrauf*
[web2py] Re: Is anyone doing Nested Lists with plugin_jqmobile?
Here is a function which may be of interest. I have included some test input data. The data is not really nested-list because it doesn't have 'lft' and 'rgt' fields. Rather this assumes that you are using a simple parent_id field to build a list suitable for superfish. If you come up with anything interesting, please let me know. def test_html_nodes(nodes,link_to_function='area'): if not nodes: nodes = [ { 'id':1, 'parent_id':None, 'name':'a' }, { 'id':2, 'parent_id':None, 'name':'b' }, { 'id':3, 'parent_id':2, 'name':'c' }, { 'id':4, 'parent_id':2, 'name':'d' }, { 'id':5, 'parent_id':4, 'name':'e' }, { 'id':6, 'parent_id':None, 'name':'f' } ] global output output = '' global count count = 0 def build_node(node): global output li_id = ' id=%s' % node['id'] output += 'li%s'%li_id + \ str(A(node['name'],_href=URL(link_to_function,args=[node[ 'id']]))) build_nodes(node['id']) output += '/li' def build_nodes(node_parent_id): global output global count count += 1 subnodes = [node for node in nodes if node['parent_id'] ==node_parent_id ] if len(subnodes) 0 : cl = ' class=sf-menu sf-vertical sf-js-enabled sf-shadow' ifcount ==1 else '' output += 'ul%s' % cl [build_node(subnode) for subnode in subnodes] output += '/ul' build_nodes(None) # Pass in None as a parent id to start with top level nodes return output
[web2py] how I can connect to SQLAnywhere database
Hi, Is wep2py support connection to Sybase SQLAnywhere 12 database. Thanks
[web2py] MHT file upload fails
When I am trying to upload an MHT file (single file holding all browser components: html, image etc.), I get an error. I observed it in old as well as new versions of web2py. Are there prohibited extensions of files which cannot be uploaded? Trace: Traceback (most recent call last): File E:\web2py1.99.7Source\gluon\main.py, line 447, in wsgibase parse_get_post_vars(request, environ) File E:\web2py1.99.7Source\gluon\main.py, line 277, in parse_get_post_vars dpost = cgi.FieldStorage(fp=request.body,environ=environ,keep_blank_values=1) File E:\Python27\lib\cgi.py, line 508, in __init__ self.read_multi(environ, keep_blank_values, strict_parsing) File E:\Python27\lib\cgi.py, line 637, in read_multi environ, keep_blank_values, strict_parsing) File E:\Python27\lib\cgi.py, line 508, in __init__ self.read_multi(environ, keep_blank_values, strict_parsing) File E:\Python27\lib\cgi.py, line 622, in read_multi raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,) ValueError: Invalid boundary in multipart form: ''
[web2py] Urlshortening appliance ERROR!
I download newest version web2py and download this appliance from https://github.com/mdipierro/web2py-appliances/tree/master/UrlShortening But when i run, i can't shorten URL. (No input form?) And when I click Bookmark button: type 'exceptions.KeyError' '127.0.0.1:8000' Traceback (most recent call last): File /home/minhcd/My_Python/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/minhcd/My_Python/web2py/applications/UrlShortening/controllers/default.py http://127.0.0.1:8000/admin/default/edit/UrlShortening/controllers/default.py, line 32, in module File /home/minhcd/My_Python/web2py/gluon/globals.py, line 175, in lambda self._caller = lambda f: f() File /home/minhcd/My_Python/web2py/gluon/tools.py, line 2665, in f return action(*a, **b) File /home/minhcd/My_Python/web2py/applications/UrlShortening/controllers/default.py http://127.0.0.1:8000/admin/default/edit/UrlShortening/controllers/default.py, line 11, in bookmark rating = cache.ram(link.url,lambda:wotrate(link.url),3600) File /home/minhcd/My_Python/web2py/gluon/cache.py, line 194, in __call__ value = f() File /home/minhcd/My_Python/web2py/applications/UrlShortening/controllers/default.py http://127.0.0.1:8000/admin/default/edit/UrlShortening/controllers/default.py, line 11, in lambda rating = cache.ram(link.url,lambda:wotrate(link.url),3600) File /home/minhcd/My_Python/web2py/applications/UrlShortening/models/myutils.py http://127.0.0.1:8000/admin/default/edit/UrlShortening/models/myutils.py, line 13, in wotrate return loads(urlopen(wot % url).read())[url] KeyError: '127.0.0.1:8000' Can you help me pls, thanks!
Re: [web2py] Is there anyone using Linode to host Web2py??
2012/4/6 Bruce Wade bruce.w...@gmail.com That script doesnt work on newer ubuntu versions uwsgi-python should just be uwsgi. Tried on 11.10 and 12.04 both failed. I was using 10.04, then I upgraded it to 11.10 and now it doesn't works anymore... why? :P
Re: [web2py] Setup virtual hosting with Web2py and apache2 mod wsgi on Ubuntu server 11.10
where ? 2012/2/8 Bruce Wade bruce.w...@gmail.com Also if you want to use uwsgi + nginx I supplied an updated script in a past post that works with Ubuntu 11.10 the default one that came with my version of web2py didn't work with Ubuntu 11.10
[web2py] how to make basic auth work?
I enable basic auth with auth.settings.allow_basic_login = True I tried wget --user=u...@bla.de --password=xxx http: //127.0.0.1:8000/pyMantis/tlc/records.json/Strain curl --head -u u...@bla.de:xxx http: //127.0.0.1:8000/pyMantis/tlc/records.json/Strain and the python code import urllib2 import base64 url = 'http://127.0.0.1:8000/pyMantis/tlc/records.json/Strain' username, password = 'u...@bla.de:xxx'.split(':') request = urllib2.Request(url) base64string = base64.encodestring('%s:%s' % (username, password)).replace( '\n', '') request.add_header(Authorization, Basic %s % base64string) fp = urllib2.urlopen(request) ... But nothing seems to work? Am I missing something?
[web2py] Re: menu issues when no subitems
This: (T('Whatever'), False, URL(...wherever...), [empty]), should be (T('Whatever'), False, URL(...wherever...), empty or []),
Re: [web2py] Re: web2py: encrypt uploaded files
I have not tried it but you can do class EncryptedField(Field): def __init__(self,*a,**b): self.password = b['password'] del b['password'] Field.__init__(self,*a,**b) def store(self,file, filename=None, path=None): newfile = encrypt(file,self.password) return Field.store(self,file,filename,path) def retrieve(self, name, path=None): (filename, file) = Field.retrieve(self,name,path) newfile = decrypt(file,self.password) return (filename, newfile) the use db.define_table('person',Field('name'),EncryptedField('secret','upload',password='too many secrets!')) On Thursday, 12 April 2012 16:35:36 UTC-5, naveed wrote: I wasn’t asking as how to encrypt the file itself, but how to incorporate it in to web2py’s existing excellent form upload and download system. Assuming that we have functions encrypt(file, password) and decrypt(file, password) which return the encrypted and decrypted file respectively. *From:* Massimo Di Pierro massimo.dipie...@gmail.com *Sent:* Wednesday, April 11, 2012 13.31 *To:* web2py@googlegroups.com *Subject:* Re: [web2py] Re: web2py: encrypt uploaded files Perhaps this can be useful: http://stackoverflow.com/questions/6309958/encrypting-a-file-with-rsa-in-python (look at code in first answer) On Wednesday, 11 April 2012 12:35:05 UTC-5, naveed wrote: Thanks Massimo for getting back. I can’t use an encrypted file system as when the file system is mounted, it’s totally open. Every file can be encrypted with the same master password. I’m thinking of storing this master password which is itself encrypted using the user’s password (or it’s hash) in the auth_user table. On a related note, I am planning to encrypt some columns of other tables using the same master password. Your thoughts on this approach? *From:* Massimo Di Pierro massimo.dipie...@gmail.com *Sent:* Wednesday, April 11, 2012 12.13 *To:* web2py@googlegroups.com *Subject:* [web2py] Re: web2py: encrypt uploaded files What are the specs? Can you store them in an encrypted file system? can you encrypt them with the same password? Should every file be encrypted with a different password? Where should the passwords be stored? On Wednesday, 11 April 2012 11:54:24 UTC-5, naveed wrote: I need to encrypt uploaded files in web2py (for a HIPAA compliant application) preferably with AES. How can I accomplish this?
[web2py] Re: how to change a field type from string to decimal?
Since there are no record you do not need conversion of string to decimals. You can do it in two steps: 1) comment the line that defines the field and run appadmin 2) uncomment the line, change the type and run appadmin done On Thursday, 12 April 2012 15:37:26 UTC-5, Carlos wrote: Hi, Is it possible (and how) to change a field type from string to decimal without recreating the table?. There are no records in the table yet, but I would like to know if there's a way to accomplish this from web2py (without recreating the database). The error I get: class 'psycopg2.ProgrammingError' column xfield__tmp is of type numeric but expression is of type character varying LINE 1: UPDATE xtable SET xfield__tmp=xfield; ^ HINT: You will need to rewrite or cast the expression. I'm using latest web2py trunk with postgresql. Thanks, Carlos
[web2py] Re: how I can connect to SQLAnywhere database
We do not have sybase support but if you can help testing, should be easy to add. On Friday, 13 April 2012 01:45:28 UTC-5, mohamed elsebaey wrote: Hi, Is wep2py support connection to Sybase SQLAnywhere 12 database. Thanks
[web2py] Re: db._adapter.reconnect()
This has nothing to do with it. Anyway, recent version of web2py have automatic reconnect, if that is what you are asking. On Friday, 13 April 2012 02:20:53 UTC-5, Johann Spies wrote: In the past, the database adapter disconnected when a constraint on the database side prohibited a transaction to complete. Will these changes make it possible to handle such a situation as an exception? I am working with Postresql. Regards Johann
[web2py] Re: Default table schema for the Auth tables
web2py's auth is take it or leave it. I disagree. You can find the definition as Anthony suggests in the source of gluon/tools.py. You can add fields with auth.settings.extra_fields['auth_user']=[Field('address')] You should not remove fields. because they are the minimum necessary to make things work. You can remove first_name and last_name but life is easier if you simply make them invisible. You do not have to use {{=auth.navbar(...)}} in your layout.html.
Re: [web2py] heroku, web2py and gunicorn
No. If you want to use gunicorn you must start web2py with anyserver -s gunicorn anyserver comes with web2py. On Friday, 13 April 2012 04:27:14 UTC-5, Rahul wrote: Hi Massimo, I am trying to explore gunicorn. Below is the command I use to activate my site. I am not sure if the parameter -s gunicorn does anything. How do I confirm this? I have gunicorn, eventlet and greenlet installed via virtualenv. I am trying to streamline my deployment and eventually remove the port number as well. * -bash-3.2$* python web2py.py -a'recycle' -i flockbird.com -p 9065 -s gunicorn Thanks, sincerely, Rahul D [www.flockbird.com] On Friday, July 22, 2011 9:33:10 PM UTC+5:30, Furqan Rauf wrote: I could do it but I am a newbie, no nothing about the deployment or stress testing On Fri, Jul 22, 2011 at 10:06 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Hello everybody, heroku will be supporting web2py. They run gunicorn. web2py runs with gunicorn but I have never tried it. Any volunteer to run some stress tests? cd web2py python anyserver -s gunicorn Massimo -- *-Furqan Rauf* *Do you love your creator? Love your fellow-beings first. -Prophet Muhammad * *http://www.amway.com/furqanrauf*
[web2py] Re: MHT file upload fails
This is either a bug in cgi.FieldStorage or in the web server. Can you send me one such file so I can look into it? On Friday, 13 April 2012 06:34:57 UTC-5, Sundar wrote: When I am trying to upload an MHT file (single file holding all browser components: html, image etc.), I get an error. I observed it in old as well as new versions of web2py. Are there prohibited extensions of files which cannot be uploaded? Trace: Traceback (most recent call last): File E:\web2py1.99.7Source\gluon\main.py, line 447, in wsgibase parse_get_post_vars(request, environ) File E:\web2py1.99.7Source\gluon\main.py, line 277, in parse_get_post_vars dpost = cgi.FieldStorage(fp=request.body,environ=environ,keep_blank_values=1) File E:\Python27\lib\cgi.py, line 508, in __init__ self.read_multi(environ, keep_blank_values, strict_parsing) File E:\Python27\lib\cgi.py, line 637, in read_multi environ, keep_blank_values, strict_parsing) File E:\Python27\lib\cgi.py, line 508, in __init__ self.read_multi(environ, keep_blank_values, strict_parsing) File E:\Python27\lib\cgi.py, line 622, in read_multi raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,) ValueError: Invalid boundary in multipart form: ''
[web2py] Re: Urlshortening appliance ERROR!
wot service cannot rate 127.0.0.1:8000 therefore it returns a json error. Not what the application expect. try to url shorten an actual live web site. * * On Friday, 13 April 2012 06:35:32 UTC-5, minhcd wrote: I download newest version web2py and download this appliance from https://github.com/mdipierro/web2py-appliances/tree/master/UrlShortening But when i run, i can't shorten URL. (No input form?) And when I click Bookmark button: type 'exceptions.KeyError' '127.0.0.1:8000' Traceback (most recent call last): File /home/minhcd/My_Python/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/minhcd/My_Python/web2py/applications/UrlShortening/controllers/default.py http://127.0.0.1:8000/admin/default/edit/UrlShortening/controllers/default.py, line 32, in module File /home/minhcd/My_Python/web2py/gluon/globals.py, line 175, in lambda self._caller = lambda f: f() File /home/minhcd/My_Python/web2py/gluon/tools.py, line 2665, in f return action(*a, **b) File /home/minhcd/My_Python/web2py/applications/UrlShortening/controllers/default.py http://127.0.0.1:8000/admin/default/edit/UrlShortening/controllers/default.py, line 11, in bookmark rating = cache.ram(link.url,lambda:wotrate(link.url),3600) File /home/minhcd/My_Python/web2py/gluon/cache.py, line 194, in __call__ value = f() File /home/minhcd/My_Python/web2py/applications/UrlShortening/controllers/default.py http://127.0.0.1:8000/admin/default/edit/UrlShortening/controllers/default.py, line 11, in lambda rating = cache.ram(link.url,lambda:wotrate(link.url),3600) File /home/minhcd/My_Python/web2py/applications/UrlShortening/models/myutils.py http://127.0.0.1:8000/admin/default/edit/UrlShortening/models/myutils.py, line 13, in wotrate return loads(urlopen(wot % url).read())[url] KeyError: '127.0.0.1:8000' Can you help me pls, thanks!
[web2py] Re: how to change a field type from string to decimal?
Hi, I wanted this to be done in a single step (web request), due to the nature of my app (dynamic db), but I see it can't. Thank you all for your replies. Carlos On Friday, April 13, 2012 8:24:29 AM UTC-5, Massimo Di Pierro wrote: Since there are no record you do not need conversion of string to decimals. You can do it in two steps: 1) comment the line that defines the field and run appadmin 2) uncomment the line, change the type and run appadmin done On Thursday, 12 April 2012 15:37:26 UTC-5, Carlos wrote: Hi, Is it possible (and how) to change a field type from string to decimal without recreating the table?. There are no records in the table yet, but I would like to know if there's a way to accomplish this from web2py (without recreating the database). The error I get: class 'psycopg2.ProgrammingError' column xfield__tmp is of type numeric but expression is of type character varying LINE 1: UPDATE xtable SET xfield__tmp=xfield; ^ HINT: You will need to rewrite or cast the expression. I'm using latest web2py trunk with postgresql. Thanks, Carlos
[web2py] Re: db._adapter.reconnect()
On Friday, 13 April 2012 15:26:48 UTC+2, Massimo Di Pierro wrote: This has nothing to do with it. Anyway, recent version of web2py have automatic reconnect, if that is what you are asking. Here is an example of what I wanted to do and which did not work in the past but I see it is now working. To me that is important progress: db.define_table('toets', Field('f1'), Field('f2')) Then in Postgresql: ALTER TABLE toets ADD CONSTRAINT geen_duplikaat UNIQUE(f1 , f2 ); def dup(): f1 = '' f2 = '' try: db.toets[0] = dict(f1 = f1, f2 = f2) except: print 'This combination is already in table toets' db.commit() return locals() In [6]: dup() dup() Out[6]: {'f1': '', 'f2': ''} In [7]: dup() dup() This combination is already in table toets Out[7]: {'f1': '', 'f2': ''} Previously the connection the connection would break and a ticket issued at this point. This enables me to make more use of database rules and constraints without having web2py do do all the work. Regards Johann
Re: [web2py] Re: db._adapter.reconnect()
In your model definition if you use : unique=True For each field, It should build your db correctly... But maybe you want both field together to be unique... I don't remember how, but I think there is a way to tell web2py about multiple column constraint. I customize validator for doing this... I can show a bit the code if you want. Richard On Fri, Apr 13, 2012 at 10:34 AM, Johann Spies johann.sp...@gmail.comwrote: On Friday, 13 April 2012 15:26:48 UTC+2, Massimo Di Pierro wrote: This has nothing to do with it. Anyway, recent version of web2py have automatic reconnect, if that is what you are asking. Here is an example of what I wanted to do and which did not work in the past but I see it is now working. To me that is important progress: db.define_table('toets', Field('f1'), Field('f2')) Then in Postgresql: ALTER TABLE toets ADD CONSTRAINT geen_duplikaat UNIQUE(f1 , f2 ); def dup(): f1 = '' f2 = '' try: db.toets[0] = dict(f1 = f1, f2 = f2) except: print 'This combination is already in table toets' db.commit() return locals() In [6]: dup() dup() Out[6]: {'f1': '', 'f2': ''} In [7]: dup() dup() This combination is already in table toets Out[7]: {'f1': '', 'f2': ''} Previously the connection the connection would break and a ticket issued at this point. This enables me to make more use of database rules and constraints without having web2py do do all the work. Regards Johann
Re: [web2py] Setup virtual hosting with Web2py and apache2 mod wsgi on Ubuntu server 11.10
You will have to search through the mail list on google. https://groups.google.com/forum/#!searchin/web2py/nginx$20update/web2py/ysmeR0mZVZo/nOBTKhPOgi8J If that doesn't work search for: Updated: uwsgi + nginx script for Ubuntu 11.10 On Fri, Apr 13, 2012 at 5:48 AM, Marco Tulio Cicero de M. Porto mtcpo...@gmail.com wrote: where ? 2012/2/8 Bruce Wade bruce.w...@gmail.com Also if you want to use uwsgi + nginx I supplied an updated script in a past post that works with Ubuntu 11.10 the default one that came with my version of web2py didn't work with Ubuntu 11.10 -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] Is there anyone using Linode to host Web2py??
uwsgi package changed. On Fri, Apr 13, 2012 at 5:35 AM, Marco Tulio Cicero de M. Porto mtcpo...@gmail.com wrote: 2012/4/6 Bruce Wade bruce.w...@gmail.com That script doesnt work on newer ubuntu versions uwsgi-python should just be uwsgi. Tried on 11.10 and 12.04 both failed. I was using 10.04, then I upgraded it to 11.10 and now it doesn't works anymore... why? :P -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
[web2py] return json with generic.json that is not an object/dictionary
is it possible to do something similar to def test(): response.generic_patterns = ['json'] return [1,2,3,4]
[web2py] session store
Hi I'm doing some tests with apache+mod_wsgi. The idea is to share sessions between two web servers. I've stored sessions in an external server (using DB and memcache), both of them wotk fine but I find that sessions stored in memcached are deleted in five minutes. Capturing web2py-memcache tcp dialog, I see that web2py stores the session key with a deletion time of 300 seconds. Can I change this value from my model/controller ? something like session.timeout? The next configuration I'd like to try is haproxy as http load balancer with sticky sessions (stored locally in each server), the idea is to always have the site available. I've noticed that some changes, for example apache config o web2py routes, require a restart of the http service because a reload doesn't work. Apache will be down for a few seconds untill it restarts, and I think haproxy will follow requests to the other server, losing the session. To avoid a single point of failure I'm thinking about: - 2 haproxy servers - N apache web servers with web2py (N = 2) - external sql/memcache to store sessions, with some kind of redundancy. The data to be accessed are legacy databases and webservices, I can't change anything there. What do you think about this configuration? Any other ideas?
Re: [web2py] Re: db._adapter.reconnect()
On 13 April 2012 16:52, Richard Vézina ml.richard.vez...@gmail.com wrote: In your model definition if you use : unique=True For each field, It should build your db correctly... But maybe you want both field together to be unique... I know about 'unique'. The constraint I used in the example makes the combination of fields unique. I don't remember how, but I think there is a way to tell web2py about multiple column constraint. I customize validator for doing this... I can show a bit the code if you want. Previously I had to use web2py code to do a database lookup before an insert to make sure that there is not already the same combination in the table. Now, I am able to let the database do the work and I do not need an extra lookup. Whatever web2py code there may be to solve a problem like this, it will not be as efficient as that of the database. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] Re: db._adapter.reconnect()
Johan, To do what you want to achieve you could look into SAVEPOINTs. PostgreSQL supports them. They allow to recover the current transaction to a predefined savepoint in case of error. The DAL does not support SAVEPOINT support, yet, but you can use them through executesql(). mic Il 13 aprile 2012 19:15, Johann Spies johann.sp...@gmail.com ha scritto: On 13 April 2012 16:52, Richard Vézina ml.richard.vez...@gmail.com wrote: In your model definition if you use : unique=True For each field, It should build your db correctly... But maybe you want both field together to be unique... I know about 'unique'. The constraint I used in the example makes the combination of fields unique. I don't remember how, but I think there is a way to tell web2py about multiple column constraint. I customize validator for doing this... I can show a bit the code if you want. Previously I had to use web2py code to do a database lookup before an insert to make sure that there is not already the same combination in the table. Now, I am able to let the database do the work and I do not need an extra lookup. Whatever web2py code there may be to solve a problem like this, it will not be as efficient as that of the database. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Database connections speed issue
Hi, When I was running the site and database on the same server there were not speed problems. However as soon as I switched to have a dedicated database server page loading becomes very very slow. Any suggestions? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] Re: db._adapter.reconnect()
On 13 April 2012 19:26, Michele Comitini michele.comit...@gmail.com wrote: Johan, To do what you want to achieve you could look into SAVEPOINTs. PostgreSQL supports them. They allow to recover the current transaction to a predefined savepoint in case of error. The DAL does not support SAVEPOINT support, yet, but you can use them through executesql(). mic Thanks! Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Overlapping periods
Hi, I try to make a function that puts periods of time into a database. The function should only add periods that doesn't overlap any of the already registered ones. But the function does not work, and I can't see what's wrong. Any idea? Thanks in advance for help! code from the controller file: def addingperiod(): if request.args and request.args[0]: item_id=request.args[0] prerecords = db().select(db.period.ALL, orderby=db.period.begindate) if not session.timedelta2==timedelta(days=0): for prerecord in prerecords: if prerecord.theauth==auth.user_id: accepted1=true accepted2=true if previous.enddate: if item_id.vars.begindate previousenddate: accepted1=false if item_id.vars.enddate prerecord.begindate: accepted2=false if item_id.vars.enddate prerecord.enddate: accepted2=false previousenddate = prerecord.enddate if accepted1==true: if accepted2==true: period.append(item_id) redirect(URL(c=request.controller,f='goal'))
Re: [web2py] Database connections speed issue
are you connecting by internal private network or over the internet? there are firewall filtering the packages? On Fri, Apr 13, 2012 at 2:33 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi, When I was running the site and database on the same server there were not speed problems. However as soon as I switched to have a dedicated database server page loading becomes very very slow. Any suggestions? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Database connections speed issue
Linode same datacenter different nodes On Apr 13, 2012 11:53 AM, Bruno Rocha rochacbr...@gmail.com wrote: are you connecting by internal private network or over the internet? there are firewall filtering the packages? On Fri, Apr 13, 2012 at 2:33 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi, When I was running the site and database on the same server there were not speed problems. However as soon as I switched to have a dedicated database server page loading becomes very very slow. Any suggestions? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Re: How to add an input field in SQLFORM.grid??
Richard, I tried Massimos approach but it created one form button rather than one for each row. For my uses, it wont cut it. I need one text field plus a button on each row. I was able to accomplish this like this links = [lambda row: INPUT(_name='qty', _value='1'), lambda row: A('+', callback=URL('cart_callback',vars=dict(id=row.id,action='add',qt=request. vars.qty)))] Maybe I did not make myself clear but I just want to have a product grid with all the products and the qty. Sort of a storefront, so the input text is not db attached. Click on the button and add it to my cart.. Hmmm but it seems you want to have like a bulk functionality with the grid, right??? On Thursday, 12 April 2012 14:27:53 UTC-7, Richard wrote: Hello Danel, May I see screenshot of what Massimo propose? I mean I would be really interrested in a bulk entry capability too. If it is already available I would know I was about to make a custom mechanism to allow user to add many result at the same time that would rely on Excel and validate_and_insert web2py method... The problem I had was to read directly Excel file, I would need to write a lot of code with xlrd. If I can avoid that I will be happy :) Thanks. Richard On Thu, Apr 12, 2012 at 5:14 PM, greenpoise danel.sega...@gmail.comwrote: Massimo, where do I change the INPUT size (length, width)? links = [lambda row: INPUT(_name='quantity', _class='integer', _value=1)] On Wednesday, 11 April 2012 18:34:16 UTC-7, Massimo Di Pierro wrote: yes and not and what I said needs clarification. grid = SQLFORM.grid(create=False,**update=False) is not a form. If create=True or update=True then it contains a form when you are creating or updating a record. you must avoind a form within a form and you can do so in the view: {{if grid.create_form or grid.update_form:}} {{=grid}} it is a form {{else:}} form{{=grid}} it is not a form but you can embed it in one input type='submit'//form {{pass}} On Wednesday, 11 April 2012 20:23:08 UTC-5, greenpoise wrote: A bit confused..I thought SQLFORM.grid was itself a form? Also, can I add more than one link per grid? Reading from the book, it creates a column so technically sounds as if I could??? On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote: You can put the grid in a form and you add SQLFORM.grid(..., link=[lambda row: INTPUT(...)]) On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote: Is this possible?? I have a products table that shows all the products. I also created an add to cart button in it problem is if I want to add 100 items I would have to press the button 100 times. Is there a way to add a quantity text field??? Thanks Dan On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote: You can put the grid in a form and you add SQLFORM.grid(..., link=[lambda row: INTPUT(...)]) On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote: Is this possible?? I have a products table that shows all the products. I also created an add to cart button in it problem is if I want to add 100 items I would have to press the button 100 times. Is there a way to add a quantity text field??? Thanks Dan
Re: [web2py] Database connections speed issue
To debug do some tests on the web2py machine using psql with -h check for the time it takes to connect to the remote postgresql server and the time to process a query. If the connection takes a long time to setup, it is most likely some dns related problem. If the queries are slow to complete, then you should check the same queries but from the server machine itself, if it is slow in both cases it is a problem with that machine, else if it is slow just on the web2py machine it is a network related problem. If there is no speed issue using psql then try doing some dal queries calling web2py on console with -S and -M options. If that is fast the problem is related to something else in the code. mic Il 13 aprile 2012 20:56, Bruce Wade bruce.w...@gmail.com ha scritto: Linode same datacenter different nodes On Apr 13, 2012 11:53 AM, Bruno Rocha rochacbr...@gmail.com wrote: are you connecting by internal private network or over the internet? there are firewall filtering the packages? On Fri, Apr 13, 2012 at 2:33 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi, When I was running the site and database on the same server there were not speed problems. However as soon as I switched to have a dedicated database server page loading becomes very very slow. Any suggestions? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Re: How to add an input field in SQLFORM.grid??
Yes I think I miss understood... What I would have is the capability to insert many records in one operation (one form submission). I thought that what Massimo suggest turn the SQLFORM.grid in a kind of multiples rows form or something like that. It was not actually clear what Massimo was doing what Massimo suggested. That why I ask you if you were willing to show a screenshot of the result. Don't mind if I actually miss understand. Cheer. Richard On Fri, Apr 13, 2012 at 3:26 PM, greenpoise danel.sega...@gmail.com wrote: Richard, I tried Massimos approach but it created one form button rather than one for each row. For my uses, it wont cut it. I need one text field plus a button on each row. I was able to accomplish this like this links = [lambda row: INPUT(_name='qty', _value='1'), lambda row: A('+', callback=URL('cart_callback',vars=dict(id=row.id,action='add',qt=request. vars.qty)))] Maybe I did not make myself clear but I just want to have a product grid with all the products and the qty. Sort of a storefront, so the input text is not db attached. Click on the button and add it to my cart.. Hmmm but it seems you want to have like a bulk functionality with the grid, right??? On Thursday, 12 April 2012 14:27:53 UTC-7, Richard wrote: Hello Danel, May I see screenshot of what Massimo propose? I mean I would be really interrested in a bulk entry capability too. If it is already available I would know I was about to make a custom mechanism to allow user to add many result at the same time that would rely on Excel and validate_and_insert web2py method... The problem I had was to read directly Excel file, I would need to write a lot of code with xlrd. If I can avoid that I will be happy :) Thanks. Richard On Thu, Apr 12, 2012 at 5:14 PM, greenpoise danel.sega...@gmail.comwrote: Massimo, where do I change the INPUT size (length, width)? links = [lambda row: INPUT(_name='quantity', _class='integer', _value=1)] On Wednesday, 11 April 2012 18:34:16 UTC-7, Massimo Di Pierro wrote: yes and not and what I said needs clarification. grid = SQLFORM.grid(create=False,**upda**te=False) is not a form. If create=True or update=True then it contains a form when you are creating or updating a record. you must avoind a form within a form and you can do so in the view: {{if grid.create_form or grid.update_form:}} {{=grid}} it is a form {{else:}} form{{=grid}} it is not a form but you can embed it in one input type='submit'//form {{pass}} On Wednesday, 11 April 2012 20:23:08 UTC-5, greenpoise wrote: A bit confused..I thought SQLFORM.grid was itself a form? Also, can I add more than one link per grid? Reading from the book, it creates a column so technically sounds as if I could??? On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote: You can put the grid in a form and you add SQLFORM.grid(..., link=[lambda row: INTPUT(...)]) On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote: Is this possible?? I have a products table that shows all the products. I also created an add to cart button in it problem is if I want to add 100 items I would have to press the button 100 times. Is there a way to add a quantity text field??? Thanks Dan On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote: You can put the grid in a form and you add SQLFORM.grid(..., link=[lambda row: INTPUT(...)]) On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote: Is this possible?? I have a products table that shows all the products. I also created an add to cart button in it problem is if I want to add 100 items I would have to press the button 100 times. Is there a way to add a quantity text field??? Thanks Dan
[web2py] SQLFORM.grid Links question
Based on this: links = [lambda row: INPUT(_name='qty', _value='1'), lambda row: A('+', callback=URL('cart_callback',vars=dict(id=row.id,action='add',qt=request. vars.qty)))] Is there a way to grab the value of the INPUT to pass them to another function??? qt=request.vars.qty does not cut it. THanks
Re: [web2py] Re: db._adapter.reconnect()
This solution look great, because until now web2py was triggering a error if postgres return not unique and won't insert the data... So, maybe as you suggest Johann this is not the case anymore with recent web2py update, I don't know. But I think we would need a confirmation about Massimo or other Core developper about that. Anyway, I will remember the Michele solution and try it, it looks effective. My only concern about that is if you don't write a custom validators that will check the constrain at the form level, the user will never understand their mystake and maybe don't even know their information have not been inserted in database if it failed silently... Richard On Fri, Apr 13, 2012 at 1:59 PM, Johann Spies johann.sp...@gmail.comwrote: On 13 April 2012 19:26, Michele Comitini michele.comit...@gmail.comwrote: Johan, To do what you want to achieve you could look into SAVEPOINTs. PostgreSQL supports them. They allow to recover the current transaction to a predefined savepoint in case of error. The DAL does not support SAVEPOINT support, yet, but you can use them through executesql(). mic Thanks! Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: return json with generic.json that is not an object/dictionary
The generic.json view expects a dictionary. You can do def test(): from gluon.serializers import json return json([1,2,3,4]) On Friday, 13 April 2012 10:15:46 UTC-5, selecta wrote: is it possible to do something similar to def test(): response.generic_patterns = ['json'] return [1,2,3,4]
Re: [web2py] Setup virtual hosting with Web2py and apache2 mod wsgi on Ubuntu server 11.10
Dude, worked like a charm, I own you. :) But it would be nice if this kind of change was also available at web2py scripts... since the other does not work to all versions of ubuntu for ex. Thanks! Marco Tulio 2012/4/13 Bruce Wade bruce.w...@gmail.com You will have to search through the mail list on google. https://groups.google.com/forum/#!searchin/web2py/nginx$20update/web2py/ysmeR0mZVZo/nOBTKhPOgi8J If that doesn't work search for: Updated: uwsgi + nginx script for Ubuntu 11.10 On Fri, Apr 13, 2012 at 5:48 AM, Marco Tulio Cicero de M. Porto mtcpo...@gmail.com wrote: where ? 2012/2/8 Bruce Wade bruce.w...@gmail.com Also if you want to use uwsgi + nginx I supplied an updated script in a past post that works with Ubuntu 11.10 the default one that came with my version of web2py didn't work with Ubuntu 11.10 -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- []'s Marco Tulio
Re: [web2py] Setup virtual hosting with Web2py and apache2 mod wsgi on Ubuntu server 11.10
Yeah I posted it in here hoping someone would have added it hint hint. Glad it worked for you. -- Regards, Bruce On Fri, Apr 13, 2012 at 2:12 PM, Marco Tulio Cicero de M. Porto mtcpo...@gmail.com wrote: Dude, worked like a charm, I own you. :) But it would be nice if this kind of change was also available at web2py scripts... since the other does not work to all versions of ubuntu for ex. Thanks! Marco Tulio 2012/4/13 Bruce Wade bruce.w...@gmail.com You will have to search through the mail list on google. https://groups.google.com/forum/#!searchin/web2py/nginx$20update/web2py/ysmeR0mZVZo/nOBTKhPOgi8J If that doesn't work search for: Updated: uwsgi + nginx script for Ubuntu 11.10 On Fri, Apr 13, 2012 at 5:48 AM, Marco Tulio Cicero de M. Porto mtcpo...@gmail.com wrote: where ? 2012/2/8 Bruce Wade bruce.w...@gmail.com Also if you want to use uwsgi + nginx I supplied an updated script in a past post that works with Ubuntu 11.10 the default one that came with my version of web2py didn't work with Ubuntu 11.10 -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- []'s Marco Tulio -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
[web2py] Re: Default table schema for the Auth tables
I think I will just make those fields invisible for now. Defining custom auth tables seem also a little risky, as it is unclear that which fields must be kept (except for auth_user, which is used as an example in the manual) for both current and future releases. Thanks all! On Friday, April 13, 2012 9:30:22 AM UTC-4, Massimo Di Pierro wrote: web2py's auth is take it or leave it. I disagree. You can find the definition as Anthony suggests in the source of gluon/tools.py. You can add fields with auth.settings.extra_fields['auth_user']=[Field('address')] You should not remove fields. because they are the minimum necessary to make things work. You can remove first_name and last_name but life is easier if you simply make them invisible. You do not have to use {{=auth.navbar(...)}} in your layout.html.
[web2py] Design of a minimal chat-like application in Web2py
Hi group, I am trying to make a minimal multiuser chat-like app using Web2py. Nothing too fancy here, I just need the app to be able to do the following: 1. client browsers can send the receive text msgs from a server 2. server may manipulate the msgs received and selectively routes those msgs to different client browsers 3. server pushes msgs to client browsers using either comet or websocket or (something else? please enlighten me here). 4. it would be nice if the server can remember the client so that if a client drops and comes back in, all the previous sent/received msgs are remembered and shown, but this is not essential. So how should I design this given the MVC model of Web2py? What extra pieces (besides Javascript on the client side) do I need? Thanks!
[web2py] Re: Design of a minimal chat-like application in Web2py
A good Stack Overflow: http://stackoverflow.com/questions/333664/simple-long-polling-example-code and article: http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery
Re: [web2py] Design of a minimal chat-like application in Web2py
Simple example with comet + tornado http://vimeo.com/38972256 (in Portuguese, but you can follow the code) On Fri, Apr 13, 2012 at 7:30 PM, cyan cyanasch...@gmail.com wrote: Hi group, I am trying to make a minimal multiuser chat-like app using Web2py. Nothing too fancy here, I just need the app to be able to do the following: 1. client browsers can send the receive text msgs from a server 2. server may manipulate the msgs received and selectively routes those msgs to different client browsers 3. server pushes msgs to client browsers using either comet or websocket or (something else? please enlighten me here). 4. it would be nice if the server can remember the client so that if a client drops and comes back in, all the previous sent/received msgs are remembered and shown, but this is not essential. So how should I design this given the MVC model of Web2py? What extra pieces (besides Javascript on the client side) do I need? Thanks! -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Database connections speed issue
psql -h connection was instant psql query was very fast no delay python web2py.py -S yaw -M connected without any problems and was fast. Think it maybe related to rotating banners, new feature. On Fri, Apr 13, 2012 at 12:30 PM, Michele Comitini michele.comit...@gmail.com wrote: To debug do some tests on the web2py machine using psql with -h check for the time it takes to connect to the remote postgresql server and the time to process a query. If the connection takes a long time to setup, it is most likely some dns related problem. If the queries are slow to complete, then you should check the same queries but from the server machine itself, if it is slow in both cases it is a problem with that machine, else if it is slow just on the web2py machine it is a network related problem. If there is no speed issue using psql then try doing some dal queries calling web2py on console with -S and -M options. If that is fast the problem is related to something else in the code. mic Il 13 aprile 2012 20:56, Bruce Wade bruce.w...@gmail.com ha scritto: Linode same datacenter different nodes On Apr 13, 2012 11:53 AM, Bruno Rocha rochacbr...@gmail.com wrote: are you connecting by internal private network or over the internet? there are firewall filtering the packages? On Fri, Apr 13, 2012 at 2:33 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi, When I was running the site and database on the same server there were not speed problems. However as soon as I switched to have a dedicated database server page loading becomes very very slow. Any suggestions? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- Bruno Rocha [http://rochacbruno.com.br] -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] Database connections speed issue
Ok I want to add when I go to admin/app/database administration it is also slow On Fri, Apr 13, 2012 at 4:17 PM, Bruce Wade bruce.w...@gmail.com wrote: psql -h connection was instant psql query was very fast no delay python web2py.py -S yaw -M connected without any problems and was fast. Think it maybe related to rotating banners, new feature. On Fri, Apr 13, 2012 at 12:30 PM, Michele Comitini michele.comit...@gmail.com wrote: To debug do some tests on the web2py machine using psql with -h check for the time it takes to connect to the remote postgresql server and the time to process a query. If the connection takes a long time to setup, it is most likely some dns related problem. If the queries are slow to complete, then you should check the same queries but from the server machine itself, if it is slow in both cases it is a problem with that machine, else if it is slow just on the web2py machine it is a network related problem. If there is no speed issue using psql then try doing some dal queries calling web2py on console with -S and -M options. If that is fast the problem is related to something else in the code. mic Il 13 aprile 2012 20:56, Bruce Wade bruce.w...@gmail.com ha scritto: Linode same datacenter different nodes On Apr 13, 2012 11:53 AM, Bruno Rocha rochacbr...@gmail.com wrote: are you connecting by internal private network or over the internet? there are firewall filtering the packages? On Fri, Apr 13, 2012 at 2:33 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi, When I was running the site and database on the same server there were not speed problems. However as soon as I switched to have a dedicated database server page loading becomes very very slow. Any suggestions? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- Bruno Rocha [http://rochacbruno.com.br] -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] Re: How to add an input field in SQLFORM.grid??
Richard, you know what? maybe it does what you want actually because what I get is a bunch of records with a txt and one submit button at the end. So, basically a grid within a form. I will write it and run it again and send you a screenshot. D On Friday, 13 April 2012 12:36:29 UTC-7, Richard wrote: Yes I think I miss understood... What I would have is the capability to insert many records in one operation (one form submission). I thought that what Massimo suggest turn the SQLFORM.grid in a kind of multiples rows form or something like that. It was not actually clear what Massimo was doing what Massimo suggested. That why I ask you if you were willing to show a screenshot of the result. Don't mind if I actually miss understand. Cheer. Richard On Fri, Apr 13, 2012 at 3:26 PM, greenpoise danel.sega...@gmail.comwrote: Richard, I tried Massimos approach but it created one form button rather than one for each row. For my uses, it wont cut it. I need one text field plus a button on each row. I was able to accomplish this like this links = [lambda row: INPUT(_name='qty', _value='1'), lambda row: A('+', callback=URL('cart_callback',vars=dict(id=row.id,action='add',qt=request. vars.qty)))] Maybe I did not make myself clear but I just want to have a product grid with all the products and the qty. Sort of a storefront, so the input text is not db attached. Click on the button and add it to my cart.. Hmmm but it seems you want to have like a bulk functionality with the grid, right??? On Thursday, 12 April 2012 14:27:53 UTC-7, Richard wrote: Hello Danel, May I see screenshot of what Massimo propose? I mean I would be really interrested in a bulk entry capability too. If it is already available I would know I was about to make a custom mechanism to allow user to add many result at the same time that would rely on Excel and validate_and_insert web2py method... The problem I had was to read directly Excel file, I would need to write a lot of code with xlrd. If I can avoid that I will be happy :) Thanks. Richard On Thu, Apr 12, 2012 at 5:14 PM, greenpoise danel.sega...@gmail.comwrote: Massimo, where do I change the INPUT size (length, width)? links = [lambda row: INPUT(_name='quantity', _class='integer', _value=1)] On Wednesday, 11 April 2012 18:34:16 UTC-7, Massimo Di Pierro wrote: yes and not and what I said needs clarification. grid = SQLFORM.grid(create=False,update=False) is not a form. If create=True or update=True then it contains a form when you are creating or updating a record. you must avoind a form within a form and you can do so in the view: {{if grid.create_form or grid.update_form:}} {{=grid}} it is a form {{else:}} form{{=grid}} it is not a form but you can embed it in one input type='submit'//form {{pass}} On Wednesday, 11 April 2012 20:23:08 UTC-5, greenpoise wrote: A bit confused..I thought SQLFORM.grid was itself a form? Also, can I add more than one link per grid? Reading from the book, it creates a column so technically sounds as if I could??? On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote: You can put the grid in a form and you add SQLFORM.grid(..., link=[lambda row: INTPUT(...)]) On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote: Is this possible?? I have a products table that shows all the products. I also created an add to cart button in it problem is if I want to add 100 items I would have to press the button 100 times. Is there a way to add a quantity text field??? Thanks Dan On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote: You can put the grid in a form and you add SQLFORM.grid(..., link=[lambda row: INTPUT(...)]) On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote: Is this possible?? I have a products table that shows all the products. I also created an add to cart button in it problem is if I want to add 100 items I would have to press the button 100 times. Is there a way to add a quantity text field??? Thanks Dan
Re: [web2py] Database connections speed issue
Ok I fixed the Major slow problem. It was a coding bug, where a session variable was checked and if it was not set the database would be queried to count all adviews currently over 12 million. however the session variable was never updated so this query was always called on every link click :( Thanks for the troubleshoot support. On Fri, Apr 13, 2012 at 4:29 PM, Bruce Wade bruce.w...@gmail.com wrote: Ok I want to add when I go to admin/app/database administration it is also slow On Fri, Apr 13, 2012 at 4:17 PM, Bruce Wade bruce.w...@gmail.com wrote: psql -h connection was instant psql query was very fast no delay python web2py.py -S yaw -M connected without any problems and was fast. Think it maybe related to rotating banners, new feature. On Fri, Apr 13, 2012 at 12:30 PM, Michele Comitini michele.comit...@gmail.com wrote: To debug do some tests on the web2py machine using psql with -h check for the time it takes to connect to the remote postgresql server and the time to process a query. If the connection takes a long time to setup, it is most likely some dns related problem. If the queries are slow to complete, then you should check the same queries but from the server machine itself, if it is slow in both cases it is a problem with that machine, else if it is slow just on the web2py machine it is a network related problem. If there is no speed issue using psql then try doing some dal queries calling web2py on console with -S and -M options. If that is fast the problem is related to something else in the code. mic Il 13 aprile 2012 20:56, Bruce Wade bruce.w...@gmail.com ha scritto: Linode same datacenter different nodes On Apr 13, 2012 11:53 AM, Bruno Rocha rochacbr...@gmail.com wrote: are you connecting by internal private network or over the internet? there are firewall filtering the packages? On Fri, Apr 13, 2012 at 2:33 PM, Bruce Wade bruce.w...@gmail.com wrote: Hi, When I was running the site and database on the same server there were not speed problems. However as soon as I switched to have a dedicated database server page loading becomes very very slow. Any suggestions? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- Bruno Rocha [http://rochacbruno.com.br] -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
[web2py] Syntax error - can not find solution
Hi all I have an application that works fine on my development machine (tested with versions 1.99.4, 1.99.7, trunk and another version (I forget) in alwaysdata) In WebFaction I have version 1.99.7 and the application throws a syntax error: Traceback (most recent call last): File /home/user/web2py/gluon/restricted.py, line 204, in restricted ccode = compile2(code,layer) File /home/user/web2py/gluon/restricted.py, line 189, in compile2 return compile(code.rstrip().replace('\r\n','\n')+'\n', layer, 'exec') File /home/user/web2py/applications/dm/controllers/default.py, line 115 retorno = DIV(*works, _id='submenu2') ^ SyntaxError: invalid syntax The code is as follows: def bg_works(): id_category = request.vars.id_category qry_category = (tb_categories_translation.category == id_category) qry_language = (tb_categories_translation.language == language_id) category = db(qry_category qry_language).select(cache=(cache.ram, 60)).first().name qry = (tb_projects.category == id_category) c = db(qry).count() rows = db(qry).select(cache=(cache.ram, 60)) if c 7: works = [SPAN( SPAN('%02d'%(n+1), _style='cursor: pointer;', _title=r.name, _onclick=$('#id_project').attr('value','%d'); ajax('bg_project',['id_project'],'project');%r.id), ' |', _class='element') for n, r in enumerate(rows)] else: works = [SPAN( SPAN(r.name, _id='work_%d'%n, _style='cursor: pointer;', _onclick=$('#id_project').attr('value','%d'); ajax('bg_project',['id_project'],'project');%r.id), ' |', _class='element') for n, r in enumerate(rows)] works.insert(0, SPAN(category, _class='category')) works.insert(0, INPUT(_type='hidden', _id='id_project', _name='id_project')) return DIV(*works, _id='submenu2') any idea? Jose
Re: [web2py] Syntax error - can not find solution
The problem is the Python Version, to pass arguments after one list unpacking *works you need to run Python 2.7+ to solve your ptoblem an run it on webfaction Python you need to replace retorno = DIV(*works, _id='submenu2') with this: retorno = DIV(*works, **{_id:'submenu2'}) On Fri, Apr 13, 2012 at 9:20 PM, Jose jjac...@gmail.com wrote: Hi all I have an application that works fine on my development machine (tested with versions 1.99.4, 1.99.7, trunk and another version (I forget) in alwaysdata) In WebFaction I have version 1.99.7 and the application throws a syntax error: Traceback (most recent call last): File /home/user/web2py/gluon/restricted.py, line 204, in restricted ccode = compile2(code,layer) File /home/user/web2py/gluon/restricted.py, line 189, in compile2 return compile(code.rstrip().replace('\r\n','\n')+'\n', layer, 'exec') File /home/user/web2py/applications/dm/controllers/default.py, line 115 retorno = DIV(*works, _id='submenu2') ^ SyntaxError: invalid syntax The code is as follows: def bg_works(): id_category = request.vars.id_category qry_category = (tb_categories_translation.category == id_category) qry_language = (tb_categories_translation.language == language_id) category = db(qry_category qry_language).select(cache=(cache.ram, 60)).first().name qry = (tb_projects.category == id_category) c = db(qry).count() rows = db(qry).select(cache=(cache.ram, 60)) if c 7: works = [SPAN( SPAN('%02d'%(n+1), _style='cursor: pointer;', _title=r.name, _onclick=$('#id_project').attr('value','%d'); ajax('bg_project',['id_project'],'project');%r.id), ' |', _class='element') for n, r in enumerate(rows)] else: works = [SPAN( SPAN(r.name, _id='work_%d'%n, _style='cursor: pointer;', _onclick=$('#id_project').attr('value','%d'); ajax('bg_project',['id_project'],'project');%r.id), ' |', _class='element') for n, r in enumerate(rows)] works.insert(0, SPAN(category, _class='category')) works.insert(0, INPUT(_type='hidden', _id='id_project', _name='id_project')) return DIV(*works, _id='submenu2') any idea? Jose -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Syntax error - can not find solution
Thanks Bruno. It works perfect
[web2py] Admin not saving data
Hi, Having a strange problem. When using admin database administration and trying to update my password when I click save it refreshes the page without any errors but also doesn't save the password. -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] Plugin Wiki, jqgrid, crud.create error
Thanks Johann, Sorry for the delay. Have just had a chance to have another play. and you're right, it does need to be defined first in the models (would have thought that it defeats some of the benefits of the adhoc nature of the plugin, but no matter) On Thursday, 12 April 2012 17:03:14 UTC+10, Johann Spies wrote: On 12 April 2012 05:38, Simon Ashley wrote: Just playing with the plugin wiki and jqgrid with a simple example below, but it return an error: Not sure why, any ideas? Did you create the table 'plant' ? I also played with this yesterday and it seems that this 'create' widget only creates a form based on the table (plant in this case). Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Curious appengine memcache exception
I am stumped by a problem I am having with memcache on App Engine. It mostly looks like a memcache issue but I am seeing something funny when I step through the code. I am getting an excpetion (TypeError: 'NoneType' object is not callable) when writing an instance to memcache. The instance comes from a simple class that should be pickleable, containing only strings, booleans, an int, and a datetime. The reason I am bringing this to the web2py board is that when I traced down the memcache call chain to a call to pickler.dump() and attempted to step into it, control jumped to code for web2py's _Web2pyImporter object in gluon/custom_import.py. Here is the relevant section of my pdb session. /Users/davidp/dev/python/google/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py(403)_do_pickle() - pickler.dump(value) (Pdb) s --Call-- /Users/davidp/dev/python/rage/gluon/custom_import.py(253)__call__() - def __call__(self, name, globals=None, locals=None, I stepped through the _Web2pyImporter code, and eventually, when executing the following statement, (line 292-3), control jumped into gluaon/dal.py where it executed the __getattr__() method of the Reference class. return super(_Web2pyImporter, self).__call__(name, globals, locals, fromlist, level) The __getattr__ returns None (it was looking up something called '__getstate__') which causes something to throw an exception. I am, by this time, just scratching my head. Why is appengine's memcache code invoking gluon code? Why is class Reference involved? The object that memcache is pickling contains no DAL references. Why is custom importing needed at all? The 'name' parameter to the Web2pyImporter function __call__ has a value of datetime. There is a datetime field in the object I'm trying to write to memcache, but why does the code jump to custom_import.py when the call to pickler.dump() is called? Here is the memcache code that was being executed at the time: def _do_pickle(self, value): Pickles a provided value. pickle_data = cStringIO.StringIO() pickler = self._pickler_factory(pickle_data, protocol=self._pickle_protocol) if self._persistent_id is not None: pickler.persistent_id = self._persistent_id pickler.dump(value)# line 403 return pickle_data.getvalue() Here is how the pdb showed the control flow as I stepped through _do_pickle(). (Pdb) n /Users/davidp/dev/python/google/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py(403)_do_pickle() - pickler.dump(value) (Pdb) s --Call-- /Users/davidp/dev/python/ragearchives/gluon/custom_import.py(253)__call__() - def __call__(self, name, globals=None, locals=None, The stack trace from the exception is copied below. Why doesn't it show the call into pickler.dump or custom_import? I am most confused. All I want to do is to store my object in memcache and my client is getting impatient. Is this a web2py issue? App Engine's memcache? Pickle? Any help would be appreciated. File applications/rage/modules/player.py, line 51, in __init__ memcache.set (key, self, Player.MEMCACHE_EXPIRATION) File /Users/davidp/dev/python/google/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py, line 778, in set namespace=namespace) File /Users/davidp/dev/python/google/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py, line 883, in _set_with_policy\ntime, \'\', namespace) File /Users/davidp/dev/python/google/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py, line 962, in _set_multi_async_with_policy stored_value, flags = _validate_encode_value(value, self._do_pickle) File /Users/davidp/dev/python/google/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py, line 227, in _validate_encode_value stored_value = do_pickle(value) File /Users/davidp/dev/python/google/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py, line 403, in _do_pickle pickler.dump(value) TypeError: 'NoneType' object is not callable
[web2py] Viewing web2py tickets on Google's devserver
How do you view web2py tickets that are generated while running on Google's devserver? When I look at a ticket using the SDK console, it is encoded in a way that I don't recognize. Like this: (dp0 S'output' p1 Stype 'exceptions.TypeError' 'NoneType' object is not callable p2 sS'layer' p3 S'/Users/davidp/dev/python/rage/applications/rage/controllers/default.py' p4 sS'code' p5 S'# -*- coding: utf-8 -*-\n'\n\n@auth.requires_login()\ndef index():\n\tresponse.title = \'Archives\'\n\n\tresponse.files.append What is this format? Is there a viewer for looking at the tickets? I can puzzle out the contents, but it is inconvenient and sometimes time consuming.
[web2py] this might be out of Web2py topic. I am trying to change the time on Ubuntu. It kept showing me UTC
I am trying to change the time on Ubuntu. It kept showing me UTC time. I tried all the method. ln -sf /usr/share/zoneinfo/UTC /etc/localtime and dpkg-reconfigure tzdata but no luck I even changed rcS to UTC=no but no goal Any Idea? I am using linode. I am sorry for unrelated topic. but after googling to find some solutions, this group is where I am at now. ;)
[web2py] Re: new feature in trunk: full auditing
I'm have been trying to test this new audit function in trunk, but so far the mything_archive table has never been created in any of my tests. Is this the current state of the implementation, or am I missing something? I downloaded the latest trunk and used it web2py admin to create a new app. I then modified db.py according to the instructions in this thread: auth = Auth(db, hmac_key=Auth.get_or_create_key()) auth.define_tables(username=True, signature=True) ... db.define_table(points, Field('type','integer'), Field('point','integer'), Field('pointname','string'), auth.signature) auth.enable_record_versioning(db) I've tried this with both mysql and sqlite databases, but no *_archive table... Any comments or suggestions? thanks, - Tom On Thursday, April 5, 2012 4:16:04 PM UTC-6, Massimo Di Pierro wrote: This is how it works: # define auth auth = Auth(db, hmac_key=Auth.get_or_create_key()) auth.define_tables(username=True,signature=True) # define your own tables like db.define_table('mything',Field('name'),auth.signature) # than do: auth.enable_record_versioning(db) how does it work? every table, including auth_user will have an auth.signature including created_by, created_on, modified_by, modified_on, is_active fields. When a record of table mything (or any other table) is modified, a copy of the previous record is copied into mything_archive which references the current record. When a record is deleted, it is not actually deleted but is_active is set to False, all records with is_active==False are filtered out in searches except in appadmin. Pros: - your app will get full record archival for auditing purposes - could not be simpler. nothing else to do. Try with SQLFORM.grid(db.mything) for example. - does not break references and there is no need for uuids - does not slow down searches because archive is done in separate archive tables Cons: - uses lots of extra memory because every version of a record is stored (it would be more efficient to store changes only but that would make more difficult to do auditing). - slows down db(...).update(...) for multi record because it needs to copy all records needing update from the original table to the archive table. This requires selecting all the records. Comments? Suggestions? On Thursday, April 5, 2012 4:16:04 PM UTC-6, Massimo Di Pierro wrote: This is how it works: # define auth auth = Auth(db, hmac_key=Auth.get_or_create_key()) auth.define_tables(username=True,signature=True) # define your own tables like db.define_table('mything',Field('name'),auth.signature) # than do: auth.enable_record_versioning(db) how does it work? every table, including auth_user will have an auth.signature including created_by, created_on, modified_by, modified_on, is_active fields. When a record of table mything (or any other table) is modified, a copy of the previous record is copied into mything_archive which references the current record. When a record is deleted, it is not actually deleted but is_active is set to False, all records with is_active==False are filtered out in searches except in appadmin. Pros: - your app will get full record archival for auditing purposes - could not be simpler. nothing else to do. Try with SQLFORM.grid(db.mything) for example. - does not break references and there is no need for uuids - does not slow down searches because archive is done in separate archive tables Cons: - uses lots of extra memory because every version of a record is stored (it would be more efficient to store changes only but that would make more difficult to do auditing). - slows down db(...).update(...) for multi record because it needs to copy all records needing update from the original table to the archive table. This requires selecting all the records. Comments? Suggestions?
[web2py] Re: Is there anyone using Linode to host Web2py??
Rackspace is full root access, they give you phone support, and it is listed on the front page of python.org. In general, the support people at many hosting services have little knowledge of Python. The least expensive cloud server is $11-12. I had Linode and they would not provide phone support. However, they do have extensive documentation. On Friday, April 6, 2012 12:14:07 AM UTC-4, Kenny wrote: I just registered for Linode to host web2py. after playing it for few hours, It doesnt seem too easy to deploy.. I followed https://groups.google.com/forum/?fromgroups#!topic/web2py/kd_A86Qwz6w by creating a script and run it. (init.deb.sh files are relocated) I think everything's followed nicely but not working. Is there anyone who can help me out by giving me instruction or info? Thank you.
[web2py] Re: this might be out of Web2py topic. I am trying to change the time on Ubuntu. It kept showing me UTC
ignore this post. My letc/localtime was corrupted. Just deleted and resymbolinked it. On Friday, April 13, 2012 9:39:02 PM UTC-7, Kenny wrote: I am trying to change the time on Ubuntu. It kept showing me UTC time. I tried all the method. ln -sf /usr/share/zoneinfo/UTC /etc/localtime and dpkg-reconfigure tzdata but no luck I even changed rcS to UTC=no but no goal Any Idea? I am using linode. I am sorry for unrelated topic. but after googling to find some solutions, this group is where I am at now. ;)