[web2py] Re: ValueError: need more than 1 value to unpack
What's inside now? Inside now contains this - import datetime; now = datetime.datetime.now() # For date time Vinicius, I am sorry about the messed up traceback - Never noticed that. simply copy-pasted the same. will take care in future (for now its pasted below again) But I don't understand why the code isnt working when I am serializing this in view? It seems to work on the db and even the below code works fine - def before_submit_of_update(form): form.vars.updated_on= now form.vars.posted_by = Rahul here now works fine. what is the problem when I am serializing it? Traceback (most recent call last): [Reformatted ] File D:\WEB2PY\web2py\gluon\restricted.py, line 194, in restrictedexec ccode in environment File D:/WEB2PY/web2py/ applications/Link_IT/controllers/default.py, line 276, in module File D:\WEB2PY\web2py\gluon\globals.py, line 149, in lambda self._caller = lambda f: f() File D:/WEB2PY/web2py/applications/ Link_IT/controllers/default.py, line 58, in indexreturn dict(form=form, list_updates=db(db.updates).select()) File D:\WEB2PY\web2py\gluon\dal.py, line 5697, in selectreturn self.db._adapter.select(self.query,fields,attributes) File D:\WEB2PY\web2py\gluon\dal.py, line 1233, in selectrows = response(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1223, in response self.execute(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1309, in executereturn self.log_execute(*a, **b) File D:\WEB2PY\web2py\gluon\dal.py, line 1304, in log_executeret = self.cursor.execute(*a,**b) File C:\Python27\lib\sqlite3\dbapi2.py, line 66, in convert_timestampdatepart, timepart = val.split( )ValueError: need more than 1 value to unpack I am working on other options for splitting etc. Thanks, Rahul D (www.flockbird.com) - web2py powered Regards, Rahul (www.flockbird.com - web2py powered) On Nov 21, 7:14 pm, Vinicius Assef vinicius...@gmail.com wrote: Rahul, this is a str.split() error and it happens when there are less pieces than str.split() expects. An example: fullname = 'John Smith' (first_name, last_name) = fullname.split( ) print 'first:', first_name, '- last:', last_name John - Smith fullname = 'John' (first_name, last_name) = fullname.split( ) Traceback (most recent call last): File pyshell#6, line 1, in module (first_name, last_name) = fullname.split( ) ValueError: need more than 1 value to unpack There weren't 2 parts in fullname. That's why the error occured. Back to your problem, the same is happening with your updated_on field. I'd make default=request.now on it. BTW, try organize the traceback. It helps people helping you. -- Vinicius Assef. On Mon, Nov 21, 2011 at 10:48 AM, Rahul rahul.dhak...@gmail.com wrote: Hi All, Is there a solution for below traceback I posted (I am on 1.99.2, win7, firefox,ie9). Tried search for a solution in below thread .. no help ... http://groups.google.com/group/web2py/browse_thread/thread/fc4a30879f... Traceback 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22. Traceback (most recent call last): File D:\WEB2PY\web2py\gluon \restricted.py, line 194, in restricted exec ccode in environment File D:/WEB2PY/web2py/applications/Link_IT/controllers/default.py, line 276, in module File D:\WEB2PY\web2py\gluon\globals.py, line 149, in lambda self._caller = lambda f: f() File D:/WEB2PY/ web2py/applications/Link_IT/controllers/default.py, line 58, in index return dict(form=form, list_updates=db(db.updates).select()) File D:\WEB2PY\web2py\gluon\dal.py, line 5697, in select return self.db._adapter.select(self.query,fields,attributes) File D:\WEB2PY \web2py\gluon\dal.py, line 1233, in select rows = response(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1223, in response self.execute(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1309, in execute return self.log_execute(*a, **b) File D:\WEB2PY\web2py \gluon\dal.py, line 1304, in log_execute ret = self.cursor.execute(*a,**b) File C:\Python27\lib\sqlite3\dbapi2.py, line 66, in convert_timestamp datepart, timepart = val.split( )ValueError: need more than 1 value to unpack here is my controller (default.py) -- def index(): return dict( list_updates=db(db.updates).select()) here is the view (index.html) - {{right_sidebar_enabled=False}} {{extend 'layout.html'}} {{=list_updates}} my model (db.py)- db.define_table('updates', Field('description', 'text'), Field('updated_on','date', readable=False, writable=False, default=now), Field('posted_by', readable=False, writable=False, length=512) ) Please help .. what could be the issue.. I even cleared the db. the issue still persists. Regards, Rahul
[web2py] Attaching a file to a mail
Hello, in our web2py based billing application we generate PDF:s that are sent to customers. So far I have always saved the PDF onto my local computer and attached that to a mail. Now I'd like to develop the app so I could send the bill directly from the app. When the PDF is created it is shown in the browser with these two rows. response.headers['Content-Type']='application/pdf' return f.render('invoice.pdf', dest='S') This is probably a pypdf question but I was hoping somebody can help me. I guess that the pyfpdf should be written to the servers harddisk and when the mail is created it picks up the file. Anybody done anything like this? Kenneth
[web2py] Re: Problem with using .as_list()
Oops, when I was testing it, I thought I could do this: fields = (db.test.id,db.test.ref,db.test.descr) db(db.test.id0).select(fields).as_list() It seems that I have to do this: db(db.test.id0).select(db.test.id,db.test.ref,db.test.descr).as_list() Sorry for confusion!
Re: [web2py] Attaching a file to a mail
remove response.headers['Content-**Type']='application/pdf' f.render(filename, dest='F') Ciao 2011/11/22 Kenneth Lundström kenneth.t.lundst...@gmail.com Hello, in our web2py based billing application we generate PDF:s that are sent to customers. So far I have always saved the PDF onto my local computer and attached that to a mail. Now I'd like to develop the app so I could send the bill directly from the app. When the PDF is created it is shown in the browser with these two rows. response.headers['Content-**Type']='application/pdf' return f.render('invoice.pdf', dest='S') This is probably a pypdf question but I was hoping somebody can help me. I guess that the pyfpdf should be written to the servers harddisk and when the mail is created it picks up the file. Anybody done anything like this? Kenneth -- Massimiliano
[web2py] Re: SQLForm.grid - How do I use it properly?
#This uses 'links' to display my virtual field 'extradate'... #Shows grid with all fields grid=SQLFORM.grid(query=(db.prop.id 10), links=[dict(header='ExtraDate', body=lambda row: row.extradate)] ) #This does the same thing but specifies fields... grid=SQLFORM.grid(query=(db.prop.id 10), links=[dict(header='ExtraDate', body=lambda row: row.extradate)], fields= (db.prop.id,db.prop.prop_ref) ) ###produces ticket ... KeyError: 'extradate' How may we make it work?
Re: [web2py] Re: ValueError: need more than 1 value to unpack
Rahul, some thoughts: 1) Your define_table() is executed at model time. When do you adjust now contents? 2) I had this problem some time ago. The situation was I had created my date field after some data was inserted in my table. So, this error happened when I tried to retrieve some old data. I cleaned my table and everything worked out. -- Vinicius Assef. On Tue, Nov 22, 2011 at 7:21 AM, Rahul rahul.dhak...@gmail.com wrote: What's inside now? Inside now contains this - import datetime; now = datetime.datetime.now() # For date time Vinicius, I am sorry about the messed up traceback - Never noticed that. simply copy-pasted the same. will take care in future (for now its pasted below again) But I don't understand why the code isnt working when I am serializing this in view? It seems to work on the db and even the below code works fine - def before_submit_of_update(form): form.vars.updated_on= now form.vars.posted_by = Rahul here now works fine. what is the problem when I am serializing it? Traceback (most recent call last): [Reformatted ] File D:\WEB2PY\web2py\gluon\restricted.py, line 194, in restricted exec ccode in environment File D:/WEB2PY/web2py/ applications/Link_IT/controllers/default.py, line 276, in module File D:\WEB2PY\web2py\gluon\globals.py, line 149, in lambda self._caller = lambda f: f() File D:/WEB2PY/web2py/applications/ Link_IT/controllers/default.py, line 58, in index return dict(form=form, list_updates=db(db.updates).select()) File D:\WEB2PY\web2py\gluon\dal.py, line 5697, in select return self.db._adapter.select(self.query,fields,attributes) File D:\WEB2PY\web2py\gluon\dal.py, line 1233, in select rows = response(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1223, in response self.execute(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1309, in execute return self.log_execute(*a, **b) File D:\WEB2PY\web2py\gluon\dal.py, line 1304, in log_execute ret = self.cursor.execute(*a,**b) File C:\Python27\lib\sqlite3\dbapi2.py, line 66, in convert_timestamp datepart, timepart = val.split( )ValueError: need more than 1 value to unpack I am working on other options for splitting etc. Thanks, Rahul D (www.flockbird.com) - web2py powered Regards, Rahul (www.flockbird.com - web2py powered) On Nov 21, 7:14 pm, Vinicius Assef vinicius...@gmail.com wrote: Rahul, this is a str.split() error and it happens when there are less pieces than str.split() expects. An example: fullname = 'John Smith' (first_name, last_name) = fullname.split( ) print 'first:', first_name, '- last:', last_name John - Smith fullname = 'John' (first_name, last_name) = fullname.split( ) Traceback (most recent call last): File pyshell#6, line 1, in module (first_name, last_name) = fullname.split( ) ValueError: need more than 1 value to unpack There weren't 2 parts in fullname. That's why the error occured. Back to your problem, the same is happening with your updated_on field. I'd make default=request.now on it. BTW, try organize the traceback. It helps people helping you. -- Vinicius Assef. On Mon, Nov 21, 2011 at 10:48 AM, Rahul rahul.dhak...@gmail.com wrote: Hi All, Is there a solution for below traceback I posted (I am on 1.99.2, win7, firefox,ie9). Tried search for a solution in below thread .. no help ... http://groups.google.com/group/web2py/browse_thread/thread/fc4a30879f... Traceback 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22. Traceback (most recent call last): File D:\WEB2PY\web2py\gluon \restricted.py, line 194, in restricted exec ccode in environment File D:/WEB2PY/web2py/applications/Link_IT/controllers/default.py, line 276, in module File D:\WEB2PY\web2py\gluon\globals.py, line 149, in lambda self._caller = lambda f: f() File D:/WEB2PY/ web2py/applications/Link_IT/controllers/default.py, line 58, in index return dict(form=form, list_updates=db(db.updates).select()) File D:\WEB2PY\web2py\gluon\dal.py, line 5697, in select return self.db._adapter.select(self.query,fields,attributes) File D:\WEB2PY \web2py\gluon\dal.py, line 1233, in select rows = response(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1223, in response self.execute(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1309, in execute return self.log_execute(*a, **b) File D:\WEB2PY\web2py \gluon\dal.py, line 1304, in log_execute ret = self.cursor.execute(*a,**b) File C:\Python27\lib\sqlite3\dbapi2.py, line 66, in convert_timestamp datepart, timepart = val.split( )ValueError: need more than 1 value to unpack here is my controller (default.py) -- def index(): return dict( list_updates=db(db.updates).select()) here is the view (index.html) - {{right_sidebar_enabled=False}} {{extend 'layout.html'}} {{=list_updates}} my model (db.py)- db.define_table('updates',
Re: [web2py] Attaching a file to a mail
Thank You. Works great now. Kenneth remove response.headers['Content-Type']='application/pdf' f.render(filename, dest='F') Ciao 2011/11/22 Kenneth Lundström kenneth.t.lundst...@gmail.com mailto:kenneth.t.lundst...@gmail.com Hello, in our web2py based billing application we generate PDF:s that are sent to customers. So far I have always saved the PDF onto my local computer and attached that to a mail. Now I'd like to develop the app so I could send the bill directly from the app. When the PDF is created it is shown in the browser with these two rows. response.headers['Content-Type']='application/pdf' return f.render('invoice.pdf', dest='S') This is probably a pypdf question but I was hoping somebody can help me. I guess that the pyfpdf should be written to the servers harddisk and when the mail is created it picks up the file. Anybody done anything like this? Kenneth -- Massimiliano
[web2py] Re: web2py and FirePHP
Tried again. The link to www.box.com is definitely returning 404. If you see content there, related to web2py, could you help me retrieve it? Thanks, Ed On Nov 20, 11:04 pm, Vineet vineet.deod...@gmail.com wrote: I can access that link. You may try to hit the link again. --- Vineet On Nov 20, 4:37 pm, Ed Greenberg greenberg...@gmail.com wrote: I happened upon this old thready from 2009:https://groups.google.com/group/web2py/browse_thread/thread/cc13960a5... But unfortunately, the link to the code has become 404 and the thread has died. Is anybody using the module that hooks web2py to FirePHP that could send me what had previously been found athttp://www.box.com/shared/dtm0dhgze9 Did it work? Many thanks Ed Greenberg
Re: [web2py] Re: Problem with using .as_list()
On 22/11/2011 11:58, villas wrote: fields = (db.test.id,db.test.ref,db.test.descr) db(db.test.id0).select(fields).as_list() It seems that I have to do this: db(db.test.id0).select(db.test.id,db.test.ref,db.test.descr).as_list() or if you prefer: fields = [db.test.id, db.test.ref, db.test.descr] db(db.test.id0).select(*fields).as_list() M.
[web2py] Re: Webfaction: Memory usage way over your limit ; again.
very useful information - thanks Robert. I got compile errors for nginx - tried multiple versions and only 0.9.6.5 built, which doesn't support --http-socket. I am on web9 which I understand is one of the older servers: http://community.webfaction.com/questions/3042/uwsgi-installation Which server did you manage to compile nginx on?
Re: [web2py] Re: Webfaction: Memory usage way over your limit ; again.
Il giorno 22/nov/2011, alle ore 14:19, Plumo ha scritto: very useful information - thanks Robert. I got compile errors for nginx - tried multiple versions and only 0.9.6.5 built, which doesn't support --http-socket. I am on web9 which I understand is one of the older servers: http://community.webfaction.com/questions/3042/uwsgi-installation Which server did you manage to compile nginx on? In the source distribution there is the directory buildconf/ that contains the various build profiles. Open default.ini and change locking = auto to locking = flock and run make this should work even in so ancient systems :) -- Roberto De Ioris http://unbit.it JID: robe...@jabber.unbit.it
[web2py] Re: import_from_csv_file problem with reference fields with 1.99.2?
I'm interested to learn the answer to this -I tried to export from SQLite and import into a MySQL database, but the references got messed up no matter what I tried... On Nov 22, 4:36 am, David Manns dgma...@gmail.com wrote: In my application which is hosted on GAE I have backup/restore functions which use export_to_csv_file/import_from_csv_file. While this is not a practical backup/restore for GAE (restore would take far too long and timeout, so for this purpose I use GAE bulk loader tool), I have used it in the past to backup from GAE and restore to test environment. This used to work fine. However, with 1.99.2, reference fields in all the tables are left with the GAE values rather than being replaced with the new ID's of the corresponding records. Both export and import were done by 1.99.2 and the import otherwise works - there is no reported failure. Is this related to issues 351 or 513 in code.google.com/p/web2py?
[web2py] Formatting numbers in SQLFORM grid
Hi, I'm trying to format numbers according to the dutch standard (decimal comma separator). It is working on view/edit views by adding: requires=IS_DECIMAL_IN_RANGE(0,100,dot=',') to the numeric field. But in list views the numbers are displayed with a decimal dot. How can I change that? Regards, Freerk
[web2py] Tornado issues
Hi All, I am working with the python package SocketTornadIO and socketio for realtime polling on web2py. The issue I am facing is that if there is an established connection and some process is on (eg.read a file and send the data to client) ; I cannot establish a connection till the first process is over . The new connection request will be in queue and will be connected after the first process is over. Though, the tornado server is asynchronous its not behaving the same. If any one had encountered similar issues then please revert if you have a solution. Thanks, Sree
[web2py] Re: SQLForm.grid - How do I use it properly?
Massimo, the issue is that the grid doesn't provide an easy way to include virtual fields. You can do it by using the 'links' argument with a dictionary for each virtual field (though that's a bit cumbersome), but then you cannot use the 'fields' argument to select only a subset of fields or the virtual fields references will fail. A workaround is to set the readable attribute of fields you don't want to include to False, but that's even more cumbersome and results in the selecting unnecessary fields. Side note: I wonder if 'links' should be changed to a more generic name, such as 'extra', since it can be used to add extra columns of any type, not just links. Anthony On Monday, November 21, 2011 9:58:18 PM UTC-5, Massimo Di Pierro wrote: I am bit lost in this thread. Can you summarize the issue? On Nov 21, 7:55 pm, villas vill...@gmail.com wrote: Yes, that's a good idea and it does seem to work. On the downside, I have a huge number of fields and I think the query will still fetch them all. Also I have to make a very long list of field.readable = False. So, if a better solution appears, I would be very grateful. However, in any case, I really do appreciate your assistance. Thank you and best regards, David
[web2py] basic auth with custom get_or_create_user call
Hello, In our project we need to create a temporary user for the web2py app so that a remote system can send back a singe status update. In order to do this, when the command is sent out we create a temporary user like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = str(uuid.uuid4()) user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) This adds the user/password to the database just fine, however, login fails because of this line in login_bare: password = table_user[passfield].validate(password)[0] if I remove this line, the password is as expected, which leads me to think that we are not adding the password in the first case properly. Does it need to be hashed some way? Matt
[web2py] Re: Formatting numbers in SQLFORM grid
Can you provide an example? Wat do you mean in list view? On Nov 22, 6:41 am, Freerk Kalsbeek fre...@mindswitch.net wrote: Hi, I'm trying to format numbers according to the dutch standard (decimal comma separator). It is working on view/edit views by adding: requires=IS_DECIMAL_IN_RANGE(0,100,dot=',') to the numeric field. But in list views the numbers are displayed with a decimal dot. How can I change that? Regards, Freerk
[web2py] Re: basic auth with custom get_or_create_user call
must be hashed settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] On Nov 22, 8:19 am, Matt Broadstone mbroa...@gmail.com wrote: Hello, In our project we need to create a temporary user for the web2py app so that a remote system can send back a singe status update. In order to do this, when the command is sent out we create a temporary user like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = str(uuid.uuid4()) user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) This adds the user/password to the database just fine, however, login fails because of this line in login_bare: password = table_user[passfield].validate(password)[0] if I remove this line, the password is as expected, which leads me to think that we are not adding the password in the first case properly. Does it need to be hashed some way? Matt
[web2py] Re: Insert references in a record
On Tuesday, November 22, 2011 12:30:42 AM UTC-5, Adrian Edwards wrote: form = SQLFORM(db.entries) form.date_entered = date.today() form.user = user if form.process().accepted: But the form won't submit. When I debug it through Eclipse it says lazyT: value not in database I don't think this is related to your error, but note that to pre-populate fields, you need to set form.vars.fieldname, not form.fieldname. Anthony
[web2py] Re: ValueError: need more than 1 value to unpack
form.vars.updated_on= now what's now? form.vars.posted_by = Rahul posted_by must be an id. On Nov 22, 3:21 am, Rahul rahul.dhak...@gmail.com wrote: What's inside now? Inside now contains this - import datetime; now = datetime.datetime.now() # For date time Vinicius, I am sorry about the messed up traceback - Never noticed that. simply copy-pasted the same. will take care in future (for now its pasted below again) But I don't understand why the code isnt working when I am serializing this in view? It seems to work on the db and even the below code works fine - def before_submit_of_update(form): form.vars.updated_on= now form.vars.posted_by = Rahul here now works fine. what is the problem when I am serializing it? Traceback (most recent call last): [Reformatted ] File D:\WEB2PY\web2py\gluon\restricted.py, line 194, in restricted exec ccode in environment File D:/WEB2PY/web2py/ applications/Link_IT/controllers/default.py, line 276, in module File D:\WEB2PY\web2py\gluon\globals.py, line 149, in lambda self._caller = lambda f: f() File D:/WEB2PY/web2py/applications/ Link_IT/controllers/default.py, line 58, in index return dict(form=form, list_updates=db(db.updates).select()) File D:\WEB2PY\web2py\gluon\dal.py, line 5697, in select return self.db._adapter.select(self.query,fields,attributes) File D:\WEB2PY\web2py\gluon\dal.py, line 1233, in select rows = response(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1223, in response self.execute(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1309, in execute return self.log_execute(*a, **b) File D:\WEB2PY\web2py\gluon\dal.py, line 1304, in log_execute ret = self.cursor.execute(*a,**b) File C:\Python27\lib\sqlite3\dbapi2.py, line 66, in convert_timestamp datepart, timepart = val.split( )ValueError: need more than 1 value to unpack I am working on other options for splitting etc. Thanks, Rahul D (www.flockbird.com) - web2py powered Regards, Rahul (www.flockbird.com- web2py powered) On Nov 21, 7:14 pm, Vinicius Assef vinicius...@gmail.com wrote: Rahul, this is a str.split() error and it happens when there are less pieces than str.split() expects. An example: fullname = 'John Smith' (first_name, last_name) = fullname.split( ) print 'first:', first_name, '- last:', last_name John - Smith fullname = 'John' (first_name, last_name) = fullname.split( ) Traceback (most recent call last): File pyshell#6, line 1, in module (first_name, last_name) = fullname.split( ) ValueError: need more than 1 value to unpack There weren't 2 parts in fullname. That's why the error occured. Back to your problem, the same is happening with your updated_on field. I'd make default=request.now on it. BTW, try organize the traceback. It helps people helping you. -- Vinicius Assef. On Mon, Nov 21, 2011 at 10:48 AM, Rahul rahul.dhak...@gmail.com wrote: Hi All, Is there a solution for below traceback I posted (I am on 1.99.2, win7, firefox,ie9). Tried search for a solution in below thread .. no help ... http://groups.google.com/group/web2py/browse_thread/thread/fc4a30879f... Traceback 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22. Traceback (most recent call last): File D:\WEB2PY\web2py\gluon \restricted.py, line 194, in restricted exec ccode in environment File D:/WEB2PY/web2py/applications/Link_IT/controllers/default.py, line 276, in module File D:\WEB2PY\web2py\gluon\globals.py, line 149, in lambda self._caller = lambda f: f() File D:/WEB2PY/ web2py/applications/Link_IT/controllers/default.py, line 58, in index return dict(form=form, list_updates=db(db.updates).select()) File D:\WEB2PY\web2py\gluon\dal.py, line 5697, in select return self.db._adapter.select(self.query,fields,attributes) File D:\WEB2PY \web2py\gluon\dal.py, line 1233, in select rows = response(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1223, in response self.execute(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1309, in execute return self.log_execute(*a, **b) File D:\WEB2PY\web2py \gluon\dal.py, line 1304, in log_execute ret = self.cursor.execute(*a,**b) File C:\Python27\lib\sqlite3\dbapi2.py, line 66, in convert_timestamp datepart, timepart = val.split( )ValueError: need more than 1 value to unpack here is my controller (default.py) -- def index(): return dict( list_updates=db(db.updates).select()) here is the view (index.html) - {{right_sidebar_enabled=False}} {{extend 'layout.html'}} {{=list_updates}} my model (db.py)- db.define_table('updates', Field('description', 'text'), Field('updated_on','date', readable=False, writable=False, default=now), Field('posted_by', readable=False, writable=False, length=512)
[web2py] tutorial on creating jquery plugins
http://www.re-cycledair.com/creating-jquery-plugins
Re: [web2py] Re: Problem with using .as_list()
Thanks Manuele, that's the shortcut I should have been using. D
[web2py] GAE Caching and Views
I am using the following decorator: @cache(request.env.path_info, time_expire=5, cache_model=cache.ram) To cache some db queries, however, when I go to deploy this on Google App Engine, I receive a PicklingError: Can't pickle type 'function': attribute lookup __builtin__.function failed You can see the traceback here: https://gist.github.com/1384892 I have a feeling the error has to do with caching a for loop in a view. You can see the view here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/views/refresh/thank_yous.html?spec=svnf8cd17ed0367521b8bd726c48ac829e920207c11r=f8cd17ed0367521b8bd726c48ac829e920207c11 You can also see the thank_yous function here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/refresh.py?spec=svnf8cd17ed0367521b8bd726c48ac829e920207c11r=f8cd17ed0367521b8bd726c48ac829e920207c11#74 I think the solution lies with creating the view within the function using return response.render() as described in the web2py book here: http://www.web2py.com/book/default/chapter/04?search=cache+view but I'm at a loss for how to do this. Does anyone have any clear examples for using response.render and an html template. Thanks!
[web2py] Re: GAE Caching and Views
How about: return response.render(dict(pledges=pledges)) An alternative is just to cache the select instead of the whole view: pledges=db((db.pledge.segment==segment_id) (db.pledge.read == False)).select(orderby=~db.pledge.created_on, cache=(cache.ram, 5)) In that case, you would remove the @cache decorator from the function. See http://www.web2py.com/book/default/chapter/06#Caching-Selects. Anthony On Tuesday, November 22, 2011 10:25:22 AM UTC-5, johntynan wrote: I am using the following decorator: @cache(request.env.path_info, time_expire=5, cache_model=cache.ram) To cache some db queries, however, when I go to deploy this on Google App Engine, I receive a PicklingError: Can't pickle type 'function': attribute lookup __builtin__.function failed You can see the traceback here: https://gist.github.com/1384892 I have a feeling the error has to do with caching a for loop in a view. You can see the view here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/views/refresh/thank_yous.html?spec=svnf8cd17ed0367521b8bd726c48ac829e920207c11r=f8cd17ed0367521b8bd726c48ac829e920207c11 You can also see the thank_yous function here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/refresh.py?spec=svnf8cd17ed0367521b8bd726c48ac829e920207c11r=f8cd17ed0367521b8bd726c48ac829e920207c11#74 I think the solution lies with creating the view within the function using return response.render() as described in the web2py book here: http://www.web2py.com/book/default/chapter/04?search=cache+view but I'm at a loss for how to do this. Does anyone have any clear examples for using response.render and an html template. Thanks!
[web2py] All fields stored as uppercase
Hi guys, my customer wants all data typed in forms, be stored in uppercase letters. What's the best way to achieve it, with little effort? -- Vinicius Assef.
[web2py] Re: Ajax and table rows.
signature from book: IS_IN_DB(db, 'person.id', '%(name)s', zero=T('choose one')) can also be: IS_IN_DB(db(query), 'person.id', '%(name)s', zero=T('choose one')) You have: IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','c ategories.name') Should be: IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','% (name)s') On Nov 21, 10:17 am, tsvim ttm...@gmail.com wrote: Ok, now that this works seems I'm still in trouble. The page I'm loading is one that has a table that I'm trying to make clickable and a form to enter more data. Here is the controller: @auth.requires_login() def budget(): db.expense.parent_table.default = request.args(0) db.expense.category.requires = IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','c ategories.name') form = crud.create(db.expense) expenses = db(db.expense.parent_table==request.args(0)).select() return dict(user=auth.user.first_name, expenses=expenses, form=form) def edit_expense(): return repr(request.vars.id) My view: table tr thDate and Time/th thTitle/th thCategory/th thAmount/th thSource/th /tr {{ for expense in expenses: }} tr class=expenses id={{=expense.id}} onmouseover=jQuery(this).attr(style.backgroundColor='lightgrey') onmouseout=jQuery(this).attr(style.backgroundColor='white') td{{=expense.datetime}}/td td{{=expense.title}}/td td{{=expense.category.name}}/td td{{=expense.amount}} {{=expense.denomination}}/td td{{=expense.source}}/td /tr {{pass}} /table hr / {{=form}} script $(document).ready(function () { $('.expenses').click(function(){ ajax('edit_expense?id=' + $(this).attr('id'), [], '#target') });}); /script div id=target/div I added the AJAX script to have it return to edit_expense the id of the row that was clicked but I get an error about the crud.create line in my controller. Thanks again for your help. Tsvi
[web2py] Re: web2py and FirePHP
I just tried, no problem. Are you behind a proxy?
[web2py] transfer auth_group data with the app
In my auth_group data I have defined a 'manager' role. The problem is that when I try to deploy my app, the db does not get transferred, so my code breaks because the 'manager' group cannot be found. Is there a way to have it initialized when the app installs in a new location? Thank you
[web2py] Re: Insert references in a record
Thanks for the feedback. I have been making progress but not quit there. Massimo - I did find some logic problems with my initial select that were contributing to the problem. Anthony - I do think that how the form is being populated is part of the problem I've been trying to build this incrementally to see at what point I'm having a problem and I've narrowed it down to the SQLFORM. I can successfully create a record manually using this code. event_users = db((db.event_users.event==event_id) (db.event_users.user_name==auth.user.id)).select(groupby=db.event_users.user_name).first() user = event_users.id date = date.today() value = '111' db.entries.insert(user=user, date_entered=date, value=value) I can also successfully create a record when I use SQLFORM and have the user enter all fields. But I don't want them to enter the user or date. I want the user to enter only the value and have the other fields be pre-populated. When I put it all together with the following code I get the errors. event_users = db((db.event_users.event==event_id) (db.event_users.user_name==auth.user.id)).select(groupby=db.event_users.user_name).first() form = SQLFORM(db.entries) form.vars.date_entered = date.today() form.vars.user = event_users.id if form.process().accepted: response.flash = 'form accepted' redirect(URL('home')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' Adrian On Nov 22, 9:24 am, Anthony abasta...@gmail.com wrote: On Tuesday, November 22, 2011 12:30:42 AM UTC-5, Adrian Edwards wrote: form = SQLFORM(db.entries) form.date_entered = date.today() form.user = user if form.process().accepted: But the form won't submit. When I debug it through Eclipse it says lazyT: value not in database I don't think this is related to your error, but note that to pre-populate fields, you need to set form.vars.fieldname, not form.fieldname. Anthony
[web2py] Re: All fields stored as uppercase
I suppose you could use the IS_UPPER() validator on all the fields -- that will convert all input to upper case for storage in DB. You could also use JS/jQuery on the client side to convert as the user types. Anthony On Tuesday, November 22, 2011 10:48:10 AM UTC-5, viniciusban wrote: Hi guys, my customer wants all data typed in forms, be stored in uppercase letters. What's the best way to achieve it, with little effort? -- Vinicius Assef.
[web2py] Re: Insert references in a record
On Tuesday, November 22, 2011 11:31:21 AM UTC-5, Adrian Edwards wrote: form = SQLFORM(db.entries) form.vars.date_entered = date.today() form.vars probably needs a string representation instead of a date object. Instead, maybe set the field's default value: db.event_users.date_entered.default = date.today()
[web2py] Re: web2py and FirePHP
I can't see it either. Oops — this shared file or folder link has been removed No proxies whatsoever. Odd... Perhaps someone could post it on another file sharing service and provide a link?
[web2py] Re: transfer auth_group data with the app
how about create a models/startup.py def startupcode(): db.commit() import os os.rename(os.path.join(request.folder,'models','startup.py'), os.path.join(request.folder,'private','startup.py')) startupcode() On Nov 22, 10:08 am, petrasadi petras...@gmail.com wrote: In my auth_group data I have defined a 'manager' role. The problem is that when I try to deploy my app, the db does not get transferred, so my code breaks because the 'manager' group cannot be found. Is there a way to have it initialized when the app installs in a new location? Thank you
[web2py] Re: Insert references in a record
I thought the same thing and so made date_entered capable of being empty and removed it from the form. Same result But I did find a hack workaround and it makes me wonder if my problem has to do with the user field being a foreign key and SQLFORM not liking that its empty (since I populate just before being processed). So I check to see if the record I'm inserting already exists, if not I insert a record with an empty value field. I then show the form, get the value entered by the user and update the record. event_users = db((db.event_users.event==event_id) (db.event_users.user_name==auth.user.id)).select(groupby=db.event_users.user_name).first() user = event_users.id entry = db((db.entries.user == user) (db.entries.date_entered == date.today())).select().first() if entry is None: id = db.entries.insert(user=user, date_entered=date.today()) entry = db(db.entries.id == id).select().first() db.entries.user.writable = False db.entries.date_entered.writable = False form = SQLFORM(db.entries, entry) if form.process().accepted: response.flash = 'form accepted' redirect(URL('home')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' I'm sure there's a much better way to do this, but its the only way I've gotten to work so far. Adrian On Nov 22, 11:41 am, Anthony abasta...@gmail.com wrote: On Tuesday, November 22, 2011 11:31:21 AM UTC-5, Adrian Edwards wrote: form = SQLFORM(db.entries) form.vars.date_entered = date.today() form.vars probably needs a string representation instead of a date object. Instead, maybe set the field's default value: db.event_users.date_entered.default = date.today()
Re: [web2py] Re: basic auth with custom get_or_create_user call
On Tue, Nov 22, 2011 at 9:21 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: must be hashed Hmm I can't seem to get this working. I should probably have mentioned that we are using basic auth to use this user on the client side. When I hash the password and insert it into the database it is not hashing the password passed in from basic login. Does this mean that we should be changing the basic method to hash the password that it finds there also? like this: (username, password) = base64.b64decode(basic[6:]).split(':') password = db.auth_user.password.validate(str(uuid.uuid4()))[0] return self.login_bare(username, password) Just to be clear, I'll reiterate what we're trying to do here. A temporary user is created in the system with a uuid username and uuid password like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) then, on the client side, we are using curl to call a restful action on the server using this login info, like this: curl https://localhost:2345/some/rest/verb -u serverUser from above:serverPassword from above and its still redirecting. I can confirm that the passwords passed in to login_bare are the same until this is called: password = table_user[passfield].validate(password)[0] settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] On Nov 22, 8:19 am, Matt Broadstone mbroa...@gmail.com wrote: Hello, In our project we need to create a temporary user for the web2py app so that a remote system can send back a singe status update. In order to do this, when the command is sent out we create a temporary user like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = str(uuid.uuid4()) user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) This adds the user/password to the database just fine, however, login fails because of this line in login_bare: password = table_user[passfield].validate(password)[0] if I remove this line, the password is as expected, which leads me to think that we are not adding the password in the first case properly. Does it need to be hashed some way? Matt
Re: [web2py] Easy handling of subforms
I think we need Massimo opinion on this... Richard On Thu, Nov 17, 2011 at 12:16 PM, ~redShadow~ redsha...@hackzine.orgwrote: On Wed, 2011-11-16 at 15:36 -0500, Richard Vézina wrote: Man! I think you got a nice solution for this exact problem... I had tried with jQuery in the pass to manage this by duplicating the field that I want to bunch insert for... It was working but was breaking the workflow of form validation if I remember... Web2py has change a lot since then and I don't know if Massimo has not resolved this issue (confirmation needed!!). But I think what you suggest is pretty neath approach and easy to implement... Web2py guru?? I suspect that you want to make insertion in multiple table... Yep, but I also want to have some control over this.. since whether to insert/update a record is determined by other form fields, the number of tables is variable and possibly there are clashing field names, ... You may be interrested by this : http://web2py.com/book/default/chapter/07?search=SQLFORM.factory#One-form-for-multiple-tables Tried that, but «This only works when the tables don't have field names in common.». Anyways, I managed to find a way that seems to work, in order to merge SQLFORMs for multiple tables, adding a namespace in front of field name, and then stripping it before doing inserts. See relevant parts from the controller source code here: http://pastebin.com/V1xwcjAg This of course could be extended to build a tree from ``form.vars``, instead of just a ``dict``-of-``dict``s (maybe by exploding ``my[var][name]``-style subscripted vars), etc.. -- Samuele ~redShadow~ Santi redshadow[at]hackzine.org - redshadowhack[at]gmail.com Blog: http://hackzine.org GPG Key signature: 050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933 /me recommends: Squadra Informatica - http://www.squadrainformatica.com - Proud ThinkPad T-Series owner - Registered Linux-User: #440008 * GENTOO User since 1199142000 (2008-01-01) * former DEBIAN SID user Software is like sex: it's better when it's free! -- Linus Torvalds
[web2py] Re: basic auth with custom get_or_create_user call
If the password is a UUID how are the users supposed to know what it and use it to login. I am missing something here. On Nov 22, 12:08 pm, Matt Broadstone mbroa...@gmail.com wrote: On Tue, Nov 22, 2011 at 9:21 AM, Massimo Di Pierromassimo.dipie...@gmail.com wrote: must be hashed Hmm I can't seem to get this working. I should probably have mentioned that we are using basic auth to use this user on the client side. When I hash the password and insert it into the database it is not hashing the password passed in from basic login. Does this mean that we should be changing the basic method to hash the password that it finds there also? like this: (username, password) = base64.b64decode(basic[6:]).split(':') password = db.auth_user.password.validate(str(uuid.uuid4()))[0] return self.login_bare(username, password) Just to be clear, I'll reiterate what we're trying to do here. A temporary user is created in the system with a uuid username and uuid password like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) then, on the client side, we are using curl to call a restful action on the server using this login info, like this: curlhttps://localhost:2345/some/rest/verb-u serverUser from above:serverPassword from above and its still redirecting. I can confirm that the passwords passed in to login_bare are the same until this is called: password = table_user[passfield].validate(password)[0] settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] On Nov 22, 8:19 am, Matt Broadstone mbroa...@gmail.com wrote: Hello, In our project we need to create a temporary user for the web2py app so that a remote system can send back a singe status update. In order to do this, when the command is sent out we create a temporary user like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = str(uuid.uuid4()) user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) This adds the user/password to the database just fine, however, login fails because of this line in login_bare: password = table_user[passfield].validate(password)[0] if I remove this line, the password is as expected, which leads me to think that we are not adding the password in the first case properly. Does it need to be hashed some way? Matt
[web2py] starting web2py with uwsgi problem.
I have a linux server (centos) When I set up my remote server, it works fine with the rocket server. However when I use uwsgi, it starts as a different user to root, and root is the owner of the web2py directories. So web2py does not work because it cannot write to the directories. Does anyone know how I can get web2py to start via uwsgi such that it is the 'root' user? (I can get things to work by setting the permissions on everything to 777 but this is clearly not ideal) Uwsgi is started with /etc/init.d/uwsgi start I am pretty inexperienced with linux. My setup is nginx with uwsgi, but no doubt the problem would be the same with apache or cherokee etc. Any help appreciated. Thanks Peter
Re: [web2py] Re: basic auth with custom get_or_create_user call
On Tue, Nov 22, 2011 at 1:32 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: If the password is a UUID how are the users supposed to know what it and use it to login. I am missing something here. its a temporary password, for a one time callback. On Nov 22, 12:08 pm, Matt Broadstone mbroa...@gmail.com wrote: On Tue, Nov 22, 2011 at 9:21 AM, Massimo Di Pierromassimo.dipie...@gmail.com wrote: must be hashed Hmm I can't seem to get this working. I should probably have mentioned that we are using basic auth to use this user on the client side. When I hash the password and insert it into the database it is not hashing the password passed in from basic login. Does this mean that we should be changing the basic method to hash the password that it finds there also? like this: (username, password) = base64.b64decode(basic[6:]).split(':') password = db.auth_user.password.validate(str(uuid.uuid4()))[0] return self.login_bare(username, password) Just to be clear, I'll reiterate what we're trying to do here. A temporary user is created in the system with a uuid username and uuid password like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) then, on the client side, we are using curl to call a restful action on the server using this login info, like this: curlhttps://localhost:2345/some/rest/verb-u serverUser from above:serverPassword from above and its still redirecting. I can confirm that the passwords passed in to login_bare are the same until this is called: password = table_user[passfield].validate(password)[0] settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] On Nov 22, 8:19 am, Matt Broadstone mbroa...@gmail.com wrote: Hello, In our project we need to create a temporary user for the web2py app so that a remote system can send back a singe status update. In order to do this, when the command is sent out we create a temporary user like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = str(uuid.uuid4()) user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) This adds the user/password to the database just fine, however, login fails because of this line in login_bare: password = table_user[passfield].validate(password)[0] if I remove this line, the password is as expected, which leads me to think that we are not adding the password in the first case properly. Does it need to be hashed some way? Matt
[web2py] Modules in modules folder don't reload
I lost some time this afternoon fighting against a bug that was already solved, but I didn't see it working. I'm importing a python module in myapp/modules folder. Changes I made there wasn't saw in browser processing. The only way to make it work was restarting web2py server. Is there any config param I can adjust to dynamically reload modules? -- Vinicius Assef.
[web2py] mail.send bug?
Hi Folks! I'm using the latest stable version of web2py and I was trying mail.send + 'logging' to test some emails... This is what I got: mail.send(to='m...@email.com') and this is what I get on my console: WARNING:web2py:email not sent From: linux...@br.ibm.com To: None Subject: m...@email.com None Why To is None and subject is using To value? Regards, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
Re: [web2py] Re: basic auth with custom get_or_create_user call
On Tue, Nov 22, 2011 at 2:31 PM, Matt Broadstone mbroa...@gmail.com wrote: On Tue, Nov 22, 2011 at 1:32 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: If the password is a UUID how are the users supposed to know what it and use it to login. I am missing something here. its a temporary password, for a one time callback. Aren't passwords always hashed when entered in the database? If so, why aren't they hashed in the basic method before they are sent to login_bare? Matt On Nov 22, 12:08 pm, Matt Broadstone mbroa...@gmail.com wrote: On Tue, Nov 22, 2011 at 9:21 AM, Massimo Di Pierromassimo.dipie...@gmail.com wrote: must be hashed Hmm I can't seem to get this working. I should probably have mentioned that we are using basic auth to use this user on the client side. When I hash the password and insert it into the database it is not hashing the password passed in from basic login. Does this mean that we should be changing the basic method to hash the password that it finds there also? like this: (username, password) = base64.b64decode(basic[6:]).split(':') password = db.auth_user.password.validate(str(uuid.uuid4()))[0] return self.login_bare(username, password) Just to be clear, I'll reiterate what we're trying to do here. A temporary user is created in the system with a uuid username and uuid password like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) then, on the client side, we are using curl to call a restful action on the server using this login info, like this: curlhttps://localhost:2345/some/rest/verb-u serverUser from above:serverPassword from above and its still redirecting. I can confirm that the passwords passed in to login_bare are the same until this is called: password = table_user[passfield].validate(password)[0] settings[serverPassword] = db.auth_user.password.validate(str(uuid.uuid4()))[0] On Nov 22, 8:19 am, Matt Broadstone mbroa...@gmail.com wrote: Hello, In our project we need to create a temporary user for the web2py app so that a remote system can send back a singe status update. In order to do this, when the command is sent out we create a temporary user like this: settings[serverUser] = str(uuid.uuid4()) settings[serverPassword] = str(uuid.uuid4()) user = auth.get_or_create_user(dict(username=settings[serverUser], password=settings[serverPassword])) This adds the user/password to the database just fine, however, login fails because of this line in login_bare: password = table_user[passfield].validate(password)[0] if I remove this line, the password is as expected, which leads me to think that we are not adding the password in the first case properly. Does it need to be hashed some way? Matt
[web2py] Can't load gaehandler
I'm trying to access a new webapp that I've deployed to a new GAE Python Dev Web Server. When I hit the default URL (http://localhost: 8080) I get the following error: dev_appserver.py:1069] Encountered error loading module gaehandler I'm using the example app.yaml that came with my web2py distribution. This yaml specifies a handler for GAE that is called 'gaehandler'. I think the error above is occurring because it can't find gaehandler.py. I've searched for this file in my project directory (which includes my web2py distribution) and the file is not there. Any thoughts on where the gaehandler is located and why the GAE Python Dev Web Server can't find it? Regards, Matt
[web2py] Web2py on pypy 1.7
It give this error: Traceback (most recent call last): File /home/angelo/DEV/web2py-dev/gluon/main.py, line 493, in wsgibase serve_controller(request, response, session) File /home/angelo/DEV/web2py-dev/gluon/main.py, line 187, in serve_controller environment = build_environment(request, response, session) File /home/angelo/DEV/web2py-dev/gluon/compileapp.py, line 269, in build_environment __builtins__['__import__'] = __builtin__.__import__ ### WHY? TypeError: 'module' object does not support item assignment I'm digging on it! -- Profile: http://www.gild.com/compagnucciangelo Register on Gild: http://www.gild.com/referral/compagnucciangelo
[web2py] Re: transfer auth_group data with the app
thank you for this, but I have one more question: is this guarantied to execute only once (upon installation).
Re: [web2py] Re: basic auth with custom get_or_create_user call
On Tuesday, November 22, 2011 3:00:46 PM UTC-5, Matt wrote: Aren't passwords always hashed when entered in the database? Not necessarily. You have to have the CRYPT() validator on the password field for hashing. It is there by default, but is not required and could be removed. Anthony
[web2py] Re: Modules in modules folder don't reload
In Python, imported modules don't reload automatically. In web2py, you can tell it to reload whenever there is a change by adding the following: from gluon.custom_import import track_changes track_changes(True) See http://web2py.com/book/default/chapter/04#Accessing-the-API-from-Python-modules. Anthony On Tuesday, November 22, 2011 2:50:58 PM UTC-5, viniciusban wrote: I lost some time this afternoon fighting against a bug that was already solved, but I didn't see it working. I'm importing a python module in myapp/modules folder. Changes I made there wasn't saw in browser processing. The only way to make it work was restarting web2py server. Is there any config param I can adjust to dynamically reload modules? -- Vinicius Assef.
Re: [web2py] Re: basic auth with custom get_or_create_user call
On Tue, Nov 22, 2011 at 3:50 PM, Anthony abasta...@gmail.com wrote: On Tuesday, November 22, 2011 3:00:46 PM UTC-5, Matt wrote: Aren't passwords always hashed when entered in the database? Not necessarily. You have to have the CRYPT() validator on the password field for hashing. It is there by default, but is not required and could be removed. Anthony Well, temporarily I have removed the password validation line: password = table_user[passfield].validate(password)[0] and everything works, but this is not ideal, as I would prefer to not have project-specific changes to gluon. Is there another solution for this? Matt
Re: [web2py] starting web2py with uwsgi problem.
Hi Peter, I'm using Apache and WSGI but this should work the same. I always run chown apache:web2py -R on an new application folder. Apache is the user that Apache is running as and web2py is the user (and group) that WSGI is running as. It is never good to run anything as root. Kenneth I have a linux server (centos) When I set up my remote server, it works fine with the rocket server. However when I use uwsgi, it starts as a different user to root, and root is the owner of the web2py directories. So web2py does not work because it cannot write to the directories. Does anyone know how I can get web2py to start via uwsgi such that it is the 'root' user? (I can get things to work by setting the permissions on everything to 777 but this is clearly not ideal) Uwsgi is started with /etc/init.d/uwsgi start I am pretty inexperienced with linux. My setup is nginx with uwsgi, but no doubt the problem would be the same with apache or cherokee etc. Any help appreciated. Thanks Peter
Re: [web2py] Re: basic auth with custom get_or_create_user call
I haven't been following the discussion. Do you want to remove the CRYPT validator? If so, I think something like: db.auth_user.password.requires = None Anthony On Tuesday, November 22, 2011 3:57:18 PM UTC-5, Matt wrote: On Tue, Nov 22, 2011 at 3:50 PM, Anthony abas...@gmail.com wrote: On Tuesday, November 22, 2011 3:00:46 PM UTC-5, Matt wrote: Aren't passwords always hashed when entered in the database? Not necessarily. You have to have the CRYPT() validator on the password field for hashing. It is there by default, but is not required and could be removed. Anthony Well, temporarily I have removed the password validation line: password = table_user[passfield].validate(password)[0] and everything works, but this is not ideal, as I would prefer to not have project-specific changes to gluon. Is there another solution for this? Matt
[web2py] Form design question
Hello again, This time I have a form design question. I have a view who's content is date dependent where if date.today() is in-between start_date and end_date then a SQLFORM is displayed. Otherwise display a custom message, i.e. Time has expired. In my first solution I added the logic in the controller that checks the date range, and then in the view did a check where if form is NoneType display the Time has expired message, otherwise display the SQLFORM fields. While this works, its not very expandable. If I now want multiple types of messages, or behavior it will make the view unwieldy. How do you think is the best way to handle this? Adrian
[web2py] Re: Can't load gaehandler
hmmm, that's odd. try re-downloading web2py? either way, gaehandler is here: http://code.google.com/p/web2py/source/browse/gaehandler.py (note that is the trunk version which may or may not match the latest released version. cfh
[web2py] Re: GAE Caching and Views
actually, unless something changed on on GAE, select caching does not work because the rows object is not picklable. the @cache decorator caches the dict that you return to the view, not the rendered view. if something in that dict is not picklable (say a rows object) the cache will fail. anthony's first suggestion should work in all cases.
[web2py] Re: mail.send bug?
That bug has been fixed in trunk. It's only the 'logging' visualization that was wrong, don't worry... On 22 Nov, 20:54, Tito Garrido titogarr...@gmail.com wrote: Hi Folks! I'm using the latest stable version of web2py and I was trying mail.send + 'logging' to test some emails... This is what I got: mail.send(to=...@email.com') and this is what I get on my console: WARNING:web2py:email not sent From: linux...@br.ibm.com To: None Subject: m...@email.com None Why To is None and subject is using To value? Regards, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
[web2py] Re: Computed Fields not updating
I have run into the above as well. Likely the issue is that on update you are not returning all values that the 'compute' field is based upon. Ex: db.define_table('test', Field('val1', 'double'), Field('val2', 'double'), Field('result', compute = lambda r: r['val1'] + r['val2']) ) Now if you have one row selected with values: id = 1, val1 = 1, val2 = 1, result = 2 in variable currRow If you do: currRow.update_record(val1 = 30) This will not use the 'compute' function Instead you need to provide all values the compute is based upon in your update... so we should have: currRow.update_record(val1 = 30, val2 = currRow.val2) This will now perform the compute method. I don't know if this is by design, but looking in the DAL the issue seems to be that the DAL only has the field data you sent to 'update' to play with. (Line 4965 of dal.py [function def_listify(self,fields,update=False) ]. (web2py v 1.99.2)
[web2py] Re: Form design question
One way to do it. There are others I'm certain... Controller if time_in_range: form = SQLFORM( if something_else: form = 'something else' # or any expression you like if another_thing: form = 'another thing' return dict(form=form) If you want to use different views, check out response.view in ch 4 of the Official Web2py Book. On Nov 22, 4:12 pm, Adrian Edwards aedward...@gmail.com wrote: Hello again, This time I have a form design question. I have a view who's content is date dependent where if date.today() is in-between start_date and end_date then a SQLFORM is displayed. Otherwise display a custom message, i.e. Time has expired. In my first solution I added the logic in the controller that checks the date range, and then in the view did a check where if form is NoneType display the Time has expired message, otherwise display the SQLFORM fields. While this works, its not very expandable. If I now want multiple types of messages, or behavior it will make the view unwieldy. How do you think is the best way to handle this? Adrian
[web2py] Re: Form design question
Thanks Cliff. I like your suggestion better. Now I can simply have the view check if type(form) is SQLFORM): display form else: ...display message On Nov 22, 5:05 pm, Cliff cjk...@gmail.com wrote: One way to do it. There are others I'm certain... Controller if time_in_range: form = SQLFORM( if something_else: form = 'something else' # or any expression you like if another_thing: form = 'another thing' return dict(form=form) If you want to use different views, check out response.view in ch 4 of the Official Web2py Book. On Nov 22, 4:12 pm, Adrian Edwards aedward...@gmail.com wrote: Hello again, This time I have a form design question. I have a view who's content is date dependent where if date.today() is in-between start_date and end_date then a SQLFORM is displayed. Otherwise display a custom message, i.e. Time has expired. In my first solution I added the logic in the controller that checks the date range, and then in the view did a check where if form is NoneType display the Time has expired message, otherwise display the SQLFORM fields. While this works, its not very expandable. If I now want multiple types of messages, or behavior it will make the view unwieldy. How do you think is the best way to handle this? Adrian
[web2py] Re: Computed Fields not updating
I should mention that I don't really use CRUD. So I've assumed the above scenario is the same as using CRUD / sqlform.smartgrid. Also, you may want to look into Virtual Fields if you don't need to actually store the data. These are computed upon retrieval of records, not insertion / updates. (But be warned, they have other stipulations, so may not fit your requirements) Finally. I don't know how to request a book submission, but I am wondering if a statement could be added to: http://web2py.com/book/default/chapter/06#Computed-Fields (first paragraph, second sentence) When a new record is modified, including both insertions and updates, if a value for the field is not provided, web2py tries to compute from the other field values using the compute function. identifying that the 'other field' values are those submitted to the 'update' / 'insert. (perhaps just add submitted so we have: When a new record is modified, including both insertions and updates, if a value for the field is not provided, web2py tries to compute from the other *submitted* field values using the compute function.
[web2py] Re: transfer auth_group data with the app
yes because the file gets moved in a different folder after execution. It is a bit of a hack. We should think of a better way On Nov 22, 2:41 pm, petrasadi petras...@gmail.com wrote: thank you for this, but I have one more question: is this guarantied to execute only once (upon installation).
[web2py] Re: GAE Caching and Views
select(cache) does not serielizes Rows but the dictionary returned by the select. I have never tried it on GAE. For sure you cannot cache in run but it should be possible to cache.memcache. If that does not work it is because the datastore returns a type that is not serializible. On Nov 22, 3:26 pm, howesc how...@umich.edu wrote: actually, unless something changed on on GAE, select caching does not work because the rows object is not picklable. the @cache decorator caches the dict that you return to the view, not the rendered view. if something in that dict is not picklable (say a rows object) the cache will fail. anthony's first suggestion should work in all cases.
[web2py] Re: transfer auth_group data with the app
Massimo's solution sure is cunning, but you might something like this a bit more maintainable: def install(): if db(db.auth_group.id 0).count() == 0: db.auth_group.insert(role = 'edit') db.auth_group.insert(role = 'moderate') db.auth_group.insert(role = 'comment') return install() On Nov 23, 11:28 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: yes because the file gets moved in a different folder after execution. It is a bit of a hack. We should think of a better way On Nov 22, 2:41 pm, petrasadi petras...@gmail.com wrote: thank you for this, but I have one more question: is this guarantied to execute only once (upon installation).- Hide quoted text - - Show quoted text -
[web2py] Re: Form design question
You can simplify the view further if you always return something named form. I'm biased in favor putting as much logic as possible in the models controllers. On Nov 22, 5:09 pm, Adrian Edwards aedward...@gmail.com wrote: Thanks Cliff. I like your suggestion better. Now I can simply have the view check if type(form) is SQLFORM): display form else: ...display message On Nov 22, 5:05 pm, Cliff cjk...@gmail.com wrote: One way to do it. There are others I'm certain... Controller if time_in_range: form = SQLFORM( if something_else: form = 'something else' # or any expression you like if another_thing: form = 'another thing' return dict(form=form) If you want to use different views, check out response.view in ch 4 of the Official Web2py Book. On Nov 22, 4:12 pm, Adrian Edwards aedward...@gmail.com wrote: Hello again, This time I have a form design question. I have a view who's content is date dependent where if date.today() is in-between start_date and end_date then a SQLFORM is displayed. Otherwise display a custom message, i.e. Time has expired. In my first solution I added the logic in the controller that checks the date range, and then in the view did a check where if form is NoneType display the Time has expired message, otherwise display the SQLFORM fields. While this works, its not very expandable. If I now want multiple types of messages, or behavior it will make the view unwieldy. How do you think is the best way to handle this? Adrian
Re: [web2py] Re: basic auth with custom get_or_create_user call
On Tue, Nov 22, 2011 at 4:11 PM, Anthony abasta...@gmail.com wrote: I haven't been following the discussion. Do you want to remove the CRYPT validator? If so, I think something like: db.auth_user.password.requires = None This seems to have fixed the issue, thank you both Matt Anthony On Tuesday, November 22, 2011 3:57:18 PM UTC-5, Matt wrote: On Tue, Nov 22, 2011 at 3:50 PM, Anthony abas...@gmail.com wrote: On Tuesday, November 22, 2011 3:00:46 PM UTC-5, Matt wrote: Aren't passwords always hashed when entered in the database? Not necessarily. You have to have the CRYPT() validator on the password field for hashing. It is there by default, but is not required and could be removed. Anthony Well, temporarily I have removed the password validation line: password = table_user[passfield].validate(password)[0] and everything works, but this is not ideal, as I would prefer to not have project-specific changes to gluon. Is there another solution for this? Matt
[web2py] Re: ERROR:Rocket.Errors.Port8000:SSL Error: [Errno 8] _ssl.c:499: EOF occurred in violation of protocol on Upgraded v1.99.1
On Nov 21, 6:42 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Please try the nightly build and let me know. I didn't check out the whole nightly build, but just replaced rocket.py and that seems to have fixed it. Matt On Nov 21, 10:07 am, Matt mbroa...@gmail.com wrote: On Nov 13, 10:54 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I think this should be be fixed in both stable and trunk. I am still seeing this error with 1.99.2, should it have been fixed there? On Nov 12, 10:38 am, Tito Garrido titogarr...@gmail.com wrote: Is it already fixed? On Thu, Sep 22, 2011 at 9:04 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Dirk and I ran some tests. 1.99.1 broke rocket with SSL. Do not upgrade if you use rocket with SSL. We will have a fix asap. Massimo On Sep 22, 4:50 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you show me what triggers it? On Sep 22, 4:39 pm, Dirk dirkl...@gmail.com wrote: Upgraded a test environment with the live update, and am seeing the following with embedded server and SSL enabled via CLI: ERROR:Rocket.Errors.Port8000:SSL Error: [Errno 8] _ssl.c:499: EOF occurred in violation of protocol TIA, Dirk -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
[web2py] Re: transfer auth_group data with the app
Though that will do an unnecessary db query on every request after the install. Anyway, you can do: if db.auth_group.isempty(): Anthony On Tuesday, November 22, 2011 6:59:58 PM UTC-5, Limedrop wrote: Massimo's solution sure is cunning, but you might something like this a bit more maintainable: def install(): if db(db.auth_group.id 0).count() == 0: db.auth_group.insert(role = 'edit') db.auth_group.insert(role = 'moderate') db.auth_group.insert(role = 'comment') return install() On Nov 23, 11:28 am, Massimo Di Pierro massimo@gmail.com wrote: yes because the file gets moved in a different folder after execution. It is a bit of a hack. We should think of a better way On Nov 22, 2:41 pm, petrasadi petr...@gmail.com wrote: thank you for this, but I have one more question: is this guarantied to execute only once (upon installation).- Hide quoted text - - Show quoted text -
[web2py] Re: Form design question
I think that makes sense, putting the logic in the controllers. Thanks for the feedback. On Nov 22, 7:38 pm, Cliff cjk...@gmail.com wrote: You can simplify the view further if you always return something named form. I'm biased in favor putting as much logic as possible in the models controllers. On Nov 22, 5:09 pm, Adrian Edwards aedward...@gmail.com wrote: Thanks Cliff. I like your suggestion better. Now I can simply have the view check if type(form) is SQLFORM): display form else: ...display message On Nov 22, 5:05 pm, Cliff cjk...@gmail.com wrote: One way to do it. There are others I'm certain... Controller if time_in_range: form = SQLFORM( if something_else: form = 'something else' # or any expression you like if another_thing: form = 'another thing' return dict(form=form) If you want to use different views, check out response.view in ch 4 of the Official Web2py Book. On Nov 22, 4:12 pm, Adrian Edwards aedward...@gmail.com wrote: Hello again, This time I have a form design question. I have a view who's content is date dependent where if date.today() is in-between start_date and end_date then a SQLFORM is displayed. Otherwise display a custom message, i.e. Time has expired. In my first solution I added the logic in the controller that checks the date range, and then in the view did a check where if form is NoneType display the Time has expired message, otherwise display the SQLFORM fields. While this works, its not very expandable. If I now want multiple types of messages, or behavior it will make the view unwieldy. How do you think is the best way to handle this? Adrian
[web2py] Re: starting web2py with uwsgi problem.
Why not set ownership of web2py files to whatever uwsgi is expecting?
Re: [web2py] Web2py on pypy 1.7
There is a ticket about this http://code.google.com/p/web2py/issues/detail?id=464 You can remove this line and everything still works normally. On Tue, Nov 22, 2011 at 6:34 PM, Angelo Compagnucci angelo.compagnu...@gmail.com wrote: It give this error: Traceback (most recent call last): File /home/angelo/DEV/web2py-dev/gluon/main.py, line 493, in wsgibase serve_controller(request, response, session) File /home/angelo/DEV/web2py-dev/gluon/main.py, line 187, in serve_controller environment = build_environment(request, response, session) File /home/angelo/DEV/web2py-dev/gluon/compileapp.py, line 269, in build_environment __builtins__['__import__'] = __builtin__.__import__ ### WHY? TypeError: 'module' object does not support item assignment I'm digging on it! -- Profile: http://www.gild.com/compagnucciangelo Register on Gild: http://www.gild.com/referral/compagnucciangelo -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: Web2py on pypy 1.7
I missed yor response. I will remove the line. On Nov 22, 10:00 pm, Bruno Rocha rochacbr...@gmail.com wrote: There is a ticket about thishttp://code.google.com/p/web2py/issues/detail?id=464 You can remove this line and everything still works normally. On Tue, Nov 22, 2011 at 6:34 PM, Angelo Compagnucci angelo.compagnu...@gmail.com wrote: It give this error: Traceback (most recent call last): File /home/angelo/DEV/web2py-dev/gluon/main.py, line 493, in wsgibase serve_controller(request, response, session) File /home/angelo/DEV/web2py-dev/gluon/main.py, line 187, in serve_controller environment = build_environment(request, response, session) File /home/angelo/DEV/web2py-dev/gluon/compileapp.py, line 269, in build_environment __builtins__['__import__'] = __builtin__.__import__ ### WHY? TypeError: 'module' object does not support item assignment I'm digging on it! -- Profile:http://www.gild.com/compagnucciangelo Register on Gild:http://www.gild.com/referral/compagnucciangelo -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: web2py and FirePHP
Ed, Sorry, I looked at the URL in your second message www.box.com and that works. The URL in your first message to a specific shared file gives me a 404 response too. This is a file sharing site like dropbox so it appears the file owner has removed it. I tried a few of the web page archives such as wayback machine, a series of them are at this URL http://www.searchengineshowdown.com/others/archive.shtml but www.box.com has a robots.txt file that prevents crawling when honoured so there is nothing in the history. Ron