Re: [web2py] Get the IP of the System
Thanks Anthony i solved it by taking the IP by using the request.env.remote_addr remote address will be there but by using the list i get it properly On Wed, Feb 29, 2012 at 9:19 AM, Anthony abasta...@gmail.com wrote: I've seen recommendations to check request.env.http_client_ip, request.env.http_x_forwarded_for, and request.env.remote_addr, in that order (remote_addr should always be there, but you want one of the other two if available because the client may be behind a proxy). Anthony On Tuesday, February 28, 2012 10:33:32 PM UTC-5, Sanjeet Kumar wrote: I want to insert the client system IP address in my database through the controller can you explain how i get the client IP address of the system when they login. On Tue, Feb 28, 2012 at 7:29 PM, Phyo Arkar phyo.arkarl...@gmail.comwrote: Which system? On 2/28/12, Sanjeet Kumar sanjeet@gmail.com wrote: How we can get the IP address of the system
[web2py] db.Table in appadmin when used in a module
I have this in a model. It is included in many tables. akb_signature = db.Table(db, 'akb_signature', Field('created_on', 'datetime', default = request.now, readable = False, writable = False), Field('created_by', db.auth_user, default = auth.user_id, readable = False, writable = False), Field('updated_on', 'datetime', default = request.now, readable = False, writable = False), Field('updated_by', db.auth_user, update = auth.user_id, readable = False, writable = False) ) While migrating table definitions to modules I used it in this way: class Inst(object): def __init__(self, db,): self.db = db self.T = current.T self.auth = current.session.auth self.tabelle = [institution, 'inst_altername'] self.define_tables() def define_tables(self): for tbl in self.tabelle: if tbl not in self.db.tables: if tbl == 'inst_altername': self.inst_alt() elif tbl == 'institution': self.institution() else: pass def institution(self): table = self.db.define_table('institution', Field('name'), ... several other fields current.akb_signature_uuid ) In appadmin I have: t = Inst(db) and it shows the table but when I edit it or insert a new record I get a ticket: KeyError: 'akb_signature_uuid' So how do I expose akb_signature_uuid in this case to appadmin? Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] web2py 1.99.5 (please read)
is the experimental model map included? or it is not done yet? http://zerp.ly/rochacbruno Em 28/02/2012 17:28, Massimo Di Pierro massimo.dipie...@gmail.com escreveu: I am planning to release this tomorrow but you can test it today. ***Please help us test it today*** It is really important. There is a huge number of improvements and bug fixes. We should really call this web2py 2.0 but we prefer to wait before advertising some of the new features which are in but need more testing. List not in order of importance: - included remote debugger (thanks Mariano) - gluon/contrib/htmlmin.py for html minimization (thanks kerncece) - out of the box posgresql support with pg8000 diver included (thanks Mariano) - admin in Russian (Bulat), Japanese (Omi) and Slovenian (Robert Valentak) - db.table.field.like(...,case_sensitive=False) (thanks Floyd) - db.table.field.regexp(...) for sqlite and postgres - conditional menu items (reponse.menu=[(title,bool,link, [],condition)] - db(...,ignore_common_filters=True) - DAL IMAP support (thanks Alan Etkin) - new DAL syntax: db(db.dog_id.belongs(db.dogs.owner=='james')).select() - new DAL syntax: db(...).select().group_by_value(db.table.field) (thanks Yair) - Teradata support (experimental) - populate can now deal with computed fields (thanks mweissen) - def index(): return dict(a=gluon.tools.Expose(folder)) - auth.is_impersonating() - reponse.delimiters = ('\\[','\\]') (thanks Denes) - improved markmin auto-links - sync languages capability (thanks Yair) - better mongodb support (still experimental) - auth.user_groups stores user groups - new rediscache (thanks niphold) - login_methods/browserid_account.py (thanks Pai) - scripts/services/service.py (thanks Ross) - improved ldap support (thanks Omi) - added TimeCollector (thanks Caleb) - better cpdb.py (thanks pasxidis) - 100's of small bug fixes and small improvements
Re: [web2py] db.Table in appadmin when used in a module
where the akb_signature_uuid is defined? in a model or module from gluon import current current.akb_signature_uuid = akb_signature_uuid = something then in appadmin from gluon import current does not works¿ http://zerp.ly/rochacbruno Em 29/02/2012 06:26, Johann Spies johann.sp...@gmail.com escreveu: I have this in a model. It is included in many tables. akb_signature = db.Table(db, 'akb_signature', Field('created_on', 'datetime', default = request.now, readable = False, writable = False), Field('created_by', db.auth_user, default = auth.user_id, readable = False, writable = False), Field('updated_on', 'datetime', default = request.now, readable = False, writable = False), Field('updated_by', db.auth_user, update = auth.user_id, readable = False, writable = False) ) While migrating table definitions to modules I used it in this way: class Inst(object): def __init__(self, db,): self.db = db self.T = current.T self.auth = current.session.auth self.tabelle = [institution, 'inst_altername'] self.define_tables() def define_tables(self): for tbl in self.tabelle: if tbl not in self.db.tables: if tbl == 'inst_altername': self.inst_alt() elif tbl == 'institution': self.institution() else: pass def institution(self): table = self.db.define_table('institution', Field('name'), ... several other fields current.akb_signature_uuid ) In appadmin I have: t = Inst(db) and it shows the table but when I edit it or insert a new record I get a ticket: KeyError: 'akb_signature_uuid' So how do I expose akb_signature_uuid in this case to appadmin? Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: After LDAP authentication, where can I change some actions?
I'm also interested in that question :-o 2011. október 30., vasárnap 2:19:20 UTC+2 időpontban Tito Garrido a következőt írta: Hi Folks! I could see that ldap authentication is located on: /web2py/gluon/contrib/login_methods but after the login I need to insert the user on some ldap groups that I've queried during the authentication... where I can do it? I can see that I won't be able to use id=db.auth_group.update_or_insert(role=g) inside of ldap_auth.py and I can see that when I've login my ldap user id has been added to user_auth table... So the question is, where can I put some code to update or insert some groups after a ldap login? Thanks! -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
[web2py] Strange grid behaviour
The same table, the same SQLFORM.grid. Just a different query using the query option in the grid: When searching in the field 'title' the grid produces shows the result and clicking on export produces a result. The same url in both cases: * http://localhost:8000/akb/doccenter/browse?keywords=akb_doccenter.title+contains+%22women%22 * Just changing the field in the same query to 'keywords' in stead of 'title' produces the following url for the grid: * http://localhost:8000/akb/doccenter/browse?keywords=akb_doccenter.keywords+contains+%22women%22 * So far so good and everything works as expected. But when I click on 'export' in the last grid the url changes to: * http://localhost:8000/akb/doccenter/browse/csv?keywords=akb_doccenter.keywords+contains+%22women%22_signature=c1e28eba26383a4f79a94ccbcc2f97e5ab7004a7 * and on the screen: *400 BAD REQUEST * I have updated my version of web2py from the trunk this morning but it is the same on an older version. Questions: * Why does the url differs that much when I try and export the two queries? * Why does not the first url (when I searched 'title') show a csv?keywords? * Why the addition of the signature on the last url and not on the first two? Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] db.Table in appadmin when used in a module
On 29 February 2012 12:05, Bruno Rocha rochacbr...@gmail.com wrote: where the akb_signature_uuid is defined? in a model or module model from gluon import current current.akb_signature_uuid = akb_signature_uuid = something In the model I have from gluon import current current.db = db current.akb_signature_uuid = akb_signature_uuid then in appadmin from gluon import current does not works¿ No not even after adding akb_signature_uuid = current.akb_signature_uuid in 'get_databases(request)' Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: Strange grid behaviour
Just a little bit of further information: 'title' has the type 'text' and 'keywords' the type 'string' in the table definition. I cannot think however that that difference can play a role the strange problem described in the prevous message. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: In plugin_wiki meta-code tables i cannot upload data :(
Guys, could any of you at least try uploading stuff to a plugin-wiki meta-code created database. Just to tell me that it's just my configuration that's broken ( i tried firefox and chromium linux ) or it's the plugin. On Mon, Feb 27, 2012 at 12:20 AM, smogzer smog...@gmail.com wrote: I'm trying to create a meta-database that can be defined via meta-code and i've come to a bug : i can't upload data to fields in that database. Could anybody fix the problem ? here is a sample code for testing. http://127.0.0.1/apagar/plugin_wiki/page_edit/meta-code code: db.define_table('imagex', Field('id','id',represent=lambda id:SPAN(id,' ',A('edit',_href=URL('page',args='edit',vars=dict(table='imagex',rec=id), Field('name'), Field('type'), Field('picture', 'upload',requires=IS_IMAGE()), format = '%(name)s') for testing http://127.0.0.1/apagar/plugin_wiki/page/edit?table=imagexrec=1 code: `` {{=plugin_wiki.widget('create',table='imagex')}} ``:template `` {{=plugin_wiki.widget('read',table=str(request.vars.table),record_id=str(request.vars.rec))}} ``:template `` {{=plugin_wiki.widget('update',table=str(request.vars.table),record_id=str(request.vars.rec))}} ``:template
[web2py] smartgrid query on 2 or more tables
Hi web2py users! 1. Can anyone tell me if the query input field on SQLform smartgrid forms can do a join on 2 or more tables? 2. If so, how do I construct such a query? My attempts my failed and can't find docs on this either... Note - I would like users to be able to construct and type in their own queries directly in the smartgrid query field. As these queries will be dynamic, doing this programmatically will be difficult - if the query can handle joins or fields from multiple tables then this should be pie :) Thanks!
[web2py] Re: web2py 1.99.5 (please read)
Massimo: I've found that the timing changes to the LOAD() helper have learnt the first lesson of not being seen. The problem is that the changes to web2py.js I submitted in the issue 576 were not updated in the welcome.w2p and it is not reflected in new applications. The new web2py.js file is stored in the welcome folder: http://code.google.com/p/web2py/source/browse/applications/welcome/static/js/web2py.js I would like to submit a new patch. In compileapp.py, if a target is specified for LOAD(), there remains the DIV with the randomly generated id and the ...loading content, but it is not updated, since the component is loaded in a target tag. Should I send the .diff to to the old issue (closed) or add a new one to the list? Bruno: You mean the IMAP adapter?. It is functional currently (in trunk).
[web2py] Re: Grid examples
FYI, the slice is updated for a few more things now. Thanks Rahul D On Feb 29, 3:06 am, greenpoise danel.sega...@gmail.com wrote: Got it, typo on my part..thanks Bruce d On Feb 28, 12:49 pm, Bruce Wade bruce.w...@gmail.com wrote: Need to see some code before anyone can help On Tue, Feb 28, 2012 at 12:47 PM, greenpoise danel.sega...@gmail.comwrote: Thanks for the lead. Why do I get duplicate grid in my view I am trying to build a simple grid and I get a duplicate grid one on top of the other. On Feb 28, 12:42 pm, Bruce Wade bruce.w...@gmail.com wrote: http://www.web2pyslices.com/slices/take_slice/148 On Tue, Feb 28, 2012 at 12:04 PM, greenpoise danel.sega...@gmail.com wrote: Any good source out there of grid examples? I am struggling even with the book in hand..The grid comes out but in an ugly manner. I just want to customize it to remove/add headings etc. Thanks dan -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f... -- -- Regards, Bruce Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp:...
Re: [web2py] Re: cron setup
I have the following code in my crontab :- 0-59/1****root **applications/welcome/cron/test.py and the following code in my test.py which are inside the cron folder in my application :- db.person.insert(name=Alex) and i want to insert this into the table person which are defined in the model db.py :- db.define_table('person', Field('name')) so please help me through this example how automatically insert/update the data in database by using cron job. On Tue, Feb 28, 2012 at 5:10 PM, Sanjeet Kumar sanjeet@gmail.comwrote: Thanks Luciano i will try. On Tue, Feb 28, 2012 at 5:06 PM, Luciano Pacheco lucm...@gmail.comwrote: I have written to you how to do that. Copy and paste: , but, in the example file, do this changes: # file: applications/instore/modules/background_updater.py from applications.instore.controllers.default import index # instead of time.sleep(5), inside the function main() index() On Tue, Feb 28, 2012 at 10:33 PM, Sanjeet Kumar sanjeet@gmail.comwrote: Yes I want to run the index function of my default controller in a cron is this possible or not ? On Tue, Feb 28, 2012 at 4:58 PM, Luciano Pacheco lucm...@gmail.comwrote: You want to run the index function of your controller in a cron ? Usually it doesn't make sense, but, in the example file # file: applications/instore/modules/background_updater.py from applications.instore.controllers.default import index # instead of time.sleep(5), inside the function main() index() I alson didn't understand what you want, if this doesn't solve your question, try explain your use case. Regards, On Tue, Feb 28, 2012 at 10:00 PM, Sanjeet Kumar sanjeet@gmail.comwrote: I am not be able to get you properly can you give me the better clarification i have the default controller and the index function can you tell me how can i run the index function by using crontab which are in my application folder. On Tue, Feb 28, 2012 at 4:12 PM, Luciano Pacheco lucm...@gmail.comwrote: Following the same example. In you controller: from applications.instore.modules.background_updater main def force_background_updater(): ret = main() return 'The result was: %s' % ret But, the cron is run time based tasks, usually those tasks won't be used in controller.One exception is when you want to force a task to run. Regards, On Tue, Feb 28, 2012 at 9:11 PM, Sanjeet Kumar sanjeet@gmail.com wrote: i tried this but i am not be able to run my controller Can you give me the simple example through which i can run the function written under the controller inside my application On Mon, Feb 27, 2012 at 5:39 PM, Luciano Pacheco lucm...@gmail.comwrote: Example: http://movu.ca/demo/article/show/31/web2py-cron-task My first try in movu.ca :-) On Mon, Feb 27, 2012 at 2:32 PM, Sanjeet Kumar sanjeet@gmail.com wrote: Exactly I need the examples On Mon, Feb 27, 2012 at 4:56 AM, Luciano Pacheco lucm...@gmail.com wrote: I think Sanjeet means, I example of the task. What is a good practice in the task, or what kind of variables are present in the local namespace automagically, etc. A task should be a class a function, a python module? I had the same question last week when I was reading this chapter. :-) Regards, -- Luciano Pacheco blog.lucmult.com.br On Mon, Feb 27, 2012 at 10:08 AM, Alan Etkin spame...@gmail.comwrote: It's all in the book (if you haven't seen yet) http://web2py.com/books/default/chapter/29/4#Cron By the way, The link in web2py to cron (http://web2py.com/books/ default/reference/29/cronhttp://web2py.com/books/default/reference/29/cron) is broken (returns an invalid function message) On 26 feb, 13:09, Sanjeet Kumar sanjeet@gmail.com wrote: Can anyone give me the brief description to how I set the cron to run the task in background with example. -- Luciano Pacheco blog.lucmult.com.br -- Luciano Pacheco blog.lucmult.com.br -- Luciano Pacheco blog.lucmult.com.br -- Luciano Pacheco blog.lucmult.com.br
[web2py] Re: web2py 1.99.5 (please read)
+1 On Feb 29, 4:35 am, Anthony abasta...@gmail.com wrote: We need to make the book editable again so some of us can start adding this stuff to the documentation. :-) On Tuesday, February 28, 2012 3:28:09 PM UTC-5, Massimo Di Pierro wrote: I am planning to release this tomorrow but you can test it today. ***Please help us test it today*** It is really important. There is a huge number of improvements and bug fixes. We should really call this web2py 2.0 but we prefer to wait before advertising some of the new features which are in but need more testing. List not in order of importance: - included remote debugger (thanks Mariano) - gluon/contrib/htmlmin.py for html minimization (thanks kerncece) - out of the box posgresql support with pg8000 diver included (thanks Mariano) - admin in Russian (Bulat), Japanese (Omi) and Slovenian (Robert Valentak) - db.table.field.like(...,case_sensitive=False) (thanks Floyd) - db.table.field.regexp(...) for sqlite and postgres - conditional menu items (reponse.menu=[(title,bool,link, [],condition)] - db(...,ignore_common_filters=True) - DAL IMAP support (thanks Alan Etkin) - new DAL syntax: db(db.dog_id.belongs(db.dogs.owner=='james')).select() - new DAL syntax: db(...).select().group_by_value(db.table.field) (thanks Yair) - Teradata support (experimental) - populate can now deal with computed fields (thanks mweissen) - def index(): return dict(a=gluon.tools.Expose(folder)) - auth.is_impersonating() - reponse.delimiters = ('\\[','\\]') (thanks Denes) - improved markmin auto-links - sync languages capability (thanks Yair) - better mongodb support (still experimental) - auth.user_groups stores user groups - new rediscache (thanks niphold) - login_methods/browserid_account.py (thanks Pai) - scripts/services/service.py (thanks Ross) - improved ldap support (thanks Omi) - added TimeCollector (thanks Caleb) - better cpdb.py (thanks pasxidis) - 100's of small bug fixes and small improvements
Re: [web2py] smartgrid query on 2 or more tables
On 29 February 2012 13:35, Roderick roderick.m...@gmail.com wrote: Hi web2py users! 1. Can anyone tell me if the query input field on SQLform smartgrid forms can do a join on 2 or more tables? If you use SQLFORM.grid the answer is 'Yes' 2. If so, how do I construct such a query? My attempts my failed and can't find docs on this either... Here is a small example: query = ((db.akb_doccenter.location == db.akb_doccenter_location.uuid) (db.akb_doccenter.category == db.akb_doccenter_category.uuid)) Fields = [db.akb_doccenter.title, db.akb_doccenter.author, db.akb_doccenter.publication_date, db.akb_doccenter.doc_nr, db.akb_doccenter_location.location, db.akb_doccenter_category.category] fields = columns opskrif = H2(T('Document Center Contents')) links = [lambda row: A('Edit' , _href = URL('doccenter', 'akb_docedit', args = [row.id]))] if auth.is_logged_in() and auth.has_membership('doccenter', auth.user.id ): data = SQLFORM.grid(query, fields = fields, orderby = db.akb_doccenter.title | db.akb_doccenter.publication_date, #links = links, editable = False, maxtextlength = 60) else: data = SQLFORM.grid(query, fields = fields, orderby = db.akb_doccenter.title | db.akb_doccenter.publication_date, deletable = False, editable = False, maxtextlength = 60) Note - I would like users to be able to construct and type in their own queries directly in the smartgrid query field. As these queries will be dynamic, doing this programmatically will be difficult - if the query can handle joins or fields from multiple tables then this should be pie :) Thanks! -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] smartgrid query on 2 or more tables
Apololgies, Gmail's web interface and I am not always friends. The above message was sent before I have finished it. Users can also build dynamic query (as long as all the tables are presented in the original query) using the search function (query-button) that comes with the grid. My experience is that users do not find that function very easy to use, so you might have to provide them with some guidelines and/or examples. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] Re: cron setup
On Wed, Feb 29, 2012 at 11:10 PM, Sanjeet Kumar sanjeet@gmail.comwrote: I have the following code in my crontab :- 0-59/1****root **applications/welcome/cron/test.py put just 1 * before applications/ [], -- Luciano Pacheco blog.lucmult.com.br
[web2py] Anyone using Dreamhost?
Can you share your experience? Thanks, Cliff Kachinske
Re: [web2py] Re: web2py 1.99.5 (please read)
no, I mean the model-execution-mapping. http://zerp.ly/rochacbruno Em 29/02/2012 09:03, Alan Etkin spame...@gmail.com escreveu: Massimo: I've found that the timing changes to the LOAD() helper have learnt the first lesson of not being seen. The problem is that the changes to web2py.js I submitted in the issue 576 were not updated in the welcome.w2p and it is not reflected in new applications. The new web2py.js file is stored in the welcome folder: http://code.google.com/p/web2py/source/browse/applications/welcome/static/js/web2py.js I would like to submit a new patch. In compileapp.py, if a target is specified for LOAD(), there remains the DIV with the randomly generated id and the ...loading content, but it is not updated, since the component is loaded in a target tag. Should I send the .diff to to the old issue (closed) or add a new one to the list? Bruno: You mean the IMAP adapter?. It is functional currently (in trunk).
[web2py] Re: image upload not being deleted - 2 questions, 1 possible bug
Question 2: How do I selectively delete the image field without deleting the entire test record? In other words, I want to delete the image file and null-out the image field, but leave the rest of the test record intact. I suppose you would have to explicitly delete the file. This is made a little more complicated by uploadseparate=True. In that case, the file is stored two sub-folders deep inside the field's uploadfolder -- the path to the file is [uploadfolder]/[tablename].[fieldname]/[first 2 characters of UUID portion of filename]. For example, the filename might be something like test.name.9d4498f37ce2b906.746573742066696c652e6a7067.jpg (the highlighted segment after the table and field name is the UUID fragment). The path to that file would be /static/data/test.name/9d/test.name.9d4498f37ce2b906.746573742066696c652e6a7067.jpg. To delete the file associated with a particular record (warning: all code below untested): file_to_delete = db(db.test.id==[id to delete]).select().first().name import os os.remove(os.path.join(db.test.name.uploadfolder, 'test.name', file_to_delete.split('.')[2][:2], file_to_delete)) You could also abstract this into a general function that also updates the db record: def delete_file(row, uploadfield): import os file = row[uploadfield] table, field, subfolder = file.split('.')[0:3] subfolder = subfolder[:2] os.remove(os.path.join(db[table][field].uploadfolder, '%s.%s' % (table, field), subfolder, file)) row.update_record(**{uploadfield: None}) Anthony
Re: [web2py] db.Table in appadmin when used in a module
Is there any reason you have a extra comma in the __init__ method? def __init__(self, db*,*): On Wed, Feb 29, 2012 at 3:14 AM, Johann Spies johann.sp...@gmail.comwrote: On 29 February 2012 12:05, Bruno Rocha rochacbr...@gmail.com wrote: where the akb_signature_uuid is defined? in a model or module model from gluon import current current.akb_signature_uuid = akb_signature_uuid = something In the model I have from gluon import current current.db = db current.akb_signature_uuid = akb_signature_uuid then in appadmin from gluon import current does not works¿ No not even after adding akb_signature_uuid = current.akb_signature_uuid in 'get_databases(request)' Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Anyone using Dreamhost?
I used them a very long time ago, but moved to hostmonster because they have better prices and service. On Wed, Feb 29, 2012 at 5:55 AM, Cliff cjk...@gmail.com wrote: Can you share your experience? Thanks, Cliff Kachinske -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Deleting upload files -- possible bug?
Grrr. Sorry to go around in circles on this. I traced my code some more and, yes, there was a bug. But I fixed it and yet the upload file is not being deleted. As improbable as it seems that this would be a bug in web2py, my Question #1 above remains open. Using the latest trunk, I tried your exact table definition (minus the reference field), and deleting a record did result in the two uploaded files being deleted as well (on Windows 7). Anthony
[web2py] Re: web2py 1.99.5 (please read)
No. It is pending this release. On Feb 29, 3:56 am, Bruno Rocha rochacbr...@gmail.com wrote: is the experimental model map included? or it is not done yet? http://zerp.ly/rochacbruno Em 28/02/2012 17:28, Massimo Di Pierro massimo.dipie...@gmail.com escreveu: I am planning to release this tomorrow but you can test it today. ***Please help us test it today*** It is really important. There is a huge number of improvements and bug fixes. We should really call this web2py 2.0 but we prefer to wait before advertising some of the new features which are in but need more testing. List not in order of importance: - included remote debugger (thanks Mariano) - gluon/contrib/htmlmin.py for html minimization (thanks kerncece) - out of the box posgresql support with pg8000 diver included (thanks Mariano) - admin in Russian (Bulat), Japanese (Omi) and Slovenian (Robert Valentak) - db.table.field.like(...,case_sensitive=False) (thanks Floyd) - db.table.field.regexp(...) for sqlite and postgres - conditional menu items (reponse.menu=[(title,bool,link, [],condition)] - db(...,ignore_common_filters=True) - DAL IMAP support (thanks Alan Etkin) - new DAL syntax: db(db.dog_id.belongs(db.dogs.owner=='james')).select() - new DAL syntax: db(...).select().group_by_value(db.table.field) (thanks Yair) - Teradata support (experimental) - populate can now deal with computed fields (thanks mweissen) - def index(): return dict(a=gluon.tools.Expose(folder)) - auth.is_impersonating() - reponse.delimiters = ('\\[','\\]') (thanks Denes) - improved markmin auto-links - sync languages capability (thanks Yair) - better mongodb support (still experimental) - auth.user_groups stores user groups - new rediscache (thanks niphold) - login_methods/browserid_account.py (thanks Pai) - scripts/services/service.py (thanks Ross) - improved ldap support (thanks Omi) - added TimeCollector (thanks Caleb) - better cpdb.py (thanks pasxidis) - 100's of small bug fixes and small improvements
[web2py] Re: web2py 1.99.5 (please read)
No. But I believe Tim knows what the problem is and is working on it. On Feb 29, 1:33 am, Phyo Arkar phyo.arkarl...@gmail.com wrote: Is the corruption of download and upload during slow connection fixed (Rocket problem) ? Thanks Phyo. On 2/29/12, Mariano Reingart reing...@gmail.com wrote: On Tue, Feb 28, 2012 at 8:08 PM, Richard Galka richard.ga...@gmail.com wrote: A couple minor points with the admin pages and the new debugging section: In the Admin - Debug - breakpoints - Add breakpoints section, if the current application has long directory file names then the table's hints run off the page. Something similar occurs when you catch an exception (debug interaction page, right pane). Maybe wrapping long filenames could be done with css. I've uploaded some screenshots at the issue: http://code.google.com/p/web2py/issues/detail?id=666 If anyone can send a css patch or a better form/layout, it would be appreciated. I think it may be pertinent to identify that in the above section, only breakpoints set through the web editor are identified. (IE: direct file edit adding breakpoints work, but are not identified in the 'breakpoints' section). That's correct, set_trace is not a real breakpoint, it just forces the debugger to stop at that line. Maybe the tip should be changed from programatically setting breakpoint using... to something better. Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com
[web2py] Re: smartgrid query on 2 or more tables
Thanks Johann! 1. Can this be done with smartgrid? 2. Can you give me an example of a dynamic query (e.g. what users would type into the search field)? (for grid or smartgrid). Thanks! On Feb 29, 2:44 pm, Johann Spies johann.sp...@gmail.com wrote: Apololgies, Gmail's web interface and I am not always friends. The above message was sent before I have finished it. Users can also build dynamic query (as long as all the tables are presented in the original query) using the search function (query-button) that comes with the grid. My experience is that users do not find that function very easy to use, so you might have to provide them with some guidelines and/or examples. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: Deleting upload files -- possible bug?
Please open a ticket, this may be a bug. On Feb 29, 8:37 am, Anthony abasta...@gmail.com wrote: Grrr. Sorry to go around in circles on this. I traced my code some more and, yes, there was a bug. But I fixed it and yet the upload file is not being deleted. As improbable as it seems that this would be a bug in web2py, my Question #1 above remains open. Using the latest trunk, I tried your exact table definition (minus the reference field), and deleting a record did result in the two uploaded files being deleted as well (on Windows 7). Anthony
[web2py] Re: Deleting upload files -- possible bug?
To be clear, I *cannot *reproduce this problem. weheh, when you delete a record, does it properly delete the file associated with the 'name' field but fail to delete the file associated with the 'image' field, or are both files being left behind? I notice the 'name' field uploads to 'static', but the 'image' field uses the default upload folder (i.e., 'uploads') -- is it possible there is a permissions issue with the 'uploads' folder? Anthony On Wednesday, February 29, 2012 9:49:46 AM UTC-5, Massimo Di Pierro wrote: Please open a ticket, this may be a bug. On Feb 29, 8:37 am, Anthony abasta...@gmail.com wrote: Grrr. Sorry to go around in circles on this. I traced my code some more and, yes, there was a bug. But I fixed it and yet the upload file is not being deleted. As improbable as it seems that this would be a bug in web2py, my Question #1 above remains open. Using the latest trunk, I tried your exact table definition (minus the reference field), and deleting a record did result in the two uploaded files being deleted as well (on Windows 7). Anthony On Wednesday, February 29, 2012 9:49:46 AM UTC-5, Massimo Di Pierro wrote: Please open a ticket, this may be a bug. On Feb 29, 8:37 am, Anthony abasta...@gmail.com wrote: Grrr. Sorry to go around in circles on this. I traced my code some more and, yes, there was a bug. But I fixed it and yet the upload file is not being deleted. As improbable as it seems that this would be a bug in web2py, my Question #1 above remains open. Using the latest trunk, I tried your exact table definition (minus the reference field), and deleting a record did result in the two uploaded files being deleted as well (on Windows 7). Anthony
[web2py] Re: Thumbnails
If you visit http://github.com/hutchi0/web2py-for-fluxflex and look at the gallery application it builds thumbnails automatically Peter On Feb 28, 9:14 pm, Bruno Rocha rochacbr...@gmail.com wrote: I do it using the compute attribute, take a look:http://movu.ca/demo/article/show/36/creating-thumbnails-with-web2py On Tue, Feb 28, 2012 at 3:32 PM, Ivan Vilches Basaul ivan_vilc...@hotmail.com wrote: Any way for automatic thumbnails creation? Thanks Ivan Vilches Basaul -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Re: Admin Disabled
Thanks that worked. My web2py process is starting with my logged in user. I did this to prevent having to su all the time, and I can do git pull and changes from a single user account. Anyway with my setup you don't need: sudo -u user_name instead you just run: python -c from gluon.widget import console; console(); python -c from gluon.main import save_password; save_password(raw_input('admin password: '),443) On Tue, Feb 28, 2012 at 6:46 PM, Bruce Wade bruce.w...@gmail.com wrote: Yes I have ssh. The site is on an amazon ubuntu instance. If my python process is running with a user other then www-data do I just change the first part of the command? sudo -u user_name python -c from gluon main import save_password; save_password(raw_input('admin password:'), 443) On Tue, Feb 28, 2012 at 5:46 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Do you have ssh access? You better do. cd under web2py/ then do: sudo -u www-data python -c from gluon.main import save_password; save_password(raw_input('admin password: '),443) replace 443 with the port you use for admin. Should be 443 for https On Feb 28, 7:15 pm, Bruce Wade bruce.w...@gmail.com wrote: For some reason the admin interface was not accepting the new password I created on my development server. Now it says admin has been disabled how do I re-enable it? -- -- Regards, Bruce Wadehttp:// ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] important - need help with file locking
I believe we have a problem with file locking. I managed to isolate the problem in this non-web2py pure-python program: begin file test.py == import fcntl import multiprocessing import unittest N=1 def lock(fp, mode): fcntl.flock(fp.fileno(), mode) def unlock(fp): fcntl.flock(fp.fileno(), fcntl.LOCK_UN) def read_write(args): (filename, iterations) = args for i in range(0, iterations): fp = open(filename,'r') lock(fp,fcntl.LOCK_SH) # shared lock content = fp.read() unlock(fp) # unlock fp.close() if len(content)!=N: return False fp = open(filename,'w') lock(fp,fcntl.LOCK_EX) # exclusive lock fp.write(content) unlock(fp) # unlock fp.close() return True class TestParallelLocks(unittest.TestCase): def setUp(self): self.filename = 'test.txt' contents = 'x'*N fp = open(self.filename,'w') fp.write(contents) fp.close() def tearDown(self): try: os.remove(self.filename) except: pass def test_reads_and_writes(self): readwriters = 10 pool = multiprocessing.Pool(processes = readwriters) results = pool.map(read_write, [[self.filename, 10]] * readwriters) for result in results: self.assertTrue(result) if __name__ == '__main__': unittest.main() = end file test.py If I run it with python test.py it will often fail the test (tested on Mac Leopard, Lion, Ubuntu, Python 2.5, 2.6, 2.7). HELP! Can you reproduce the problem? Do you see anything wrong with the code? Massimo
[web2py] Re: important - need help with file locking
Found the problem with some help from a friend in the Chicago Python users group. One problem is flushing before unlocking the file. Another is that opening the file for writing truncates the file before the exclusive lock is acquired. On Feb 29, 11:46 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I believe we have a problem with file locking. I managed to isolate the problem in this non-web2py pure-python program: begin file test.py == import fcntl import multiprocessing import unittest N=1 def lock(fp, mode): fcntl.flock(fp.fileno(), mode) def unlock(fp): fcntl.flock(fp.fileno(), fcntl.LOCK_UN) def read_write(args): (filename, iterations) = args for i in range(0, iterations): fp = open(filename,'r') lock(fp,fcntl.LOCK_SH) # shared lock content = fp.read() unlock(fp) # unlock fp.close() if len(content)!=N: return False fp = open(filename,'w') lock(fp,fcntl.LOCK_EX) # exclusive lock fp.write(content) unlock(fp) # unlock fp.close() return True class TestParallelLocks(unittest.TestCase): def setUp(self): self.filename = 'test.txt' contents = 'x'*N fp = open(self.filename,'w') fp.write(contents) fp.close() def tearDown(self): try: os.remove(self.filename) except: pass def test_reads_and_writes(self): readwriters = 10 pool = multiprocessing.Pool(processes = readwriters) results = pool.map(read_write, [[self.filename, 10]] * readwriters) for result in results: self.assertTrue(result) if __name__ == '__main__': unittest.main() = end file test.py If I run it with python test.py it will often fail the test (tested on Mac Leopard, Lion, Ubuntu, Python 2.5, 2.6, 2.7). HELP! Can you reproduce the problem? Do you see anything wrong with the code? Massimo
[web2py] Re: Possible bug with a referenced field?
Hi, I attached a file with code that reproduces the problem. For this example I expect to only return options African and Swallow, not John and not Doe. I traced the problem back to the call from sqlhtml.py on line 217 to the IS_IN_DB validators function options(). I'm not sure if the fix should be in the widget or in the IS_IN_DB validator. Personally I'd fix it in the IS_IN_DB validator, but then that might break the way request_tenant was intended to behave and/or break backwards compatibiity. If you tell me where you want it fixed I might be able to cook up a patch over the weekend, Thanks, Tsvi On Wednesday, February 29, 2012 12:47:04 AM UTC+2, tsvim wrote: Hi, In my models I have 2 tables, where table 1 has field a referencing table 2. As each user has a bunch of fields both in table 1 as well as in table 2, I used the request_tenant field with some uuid in both tables which is tied to the user (I'm not using the users ID for various reasons). I tried creating a form for table 1 with SQLFORM, but the select dropdown for field a returns all the items in table 2, and doesn't filter them according to the request_tenant field, which I would consider the correct behavior. I'll show some code tomorrow. Can you confirm this being a bug? Or am I missing something? Thanks, Tsvi Sent from my phone On Wednesday, February 29, 2012 12:47:04 AM UTC+2, tsvim wrote: Hi, In my models I have 2 tables, where table 1 has field a referencing table 2. As each user has a bunch of fields both in table 1 as well as in table 2, I used the request_tenant field with some uuid in both tables which is tied to the user (I'm not using the users ID for various reasons). I tried creating a form for table 1 with SQLFORM, but the select dropdown for field a returns all the items in table 2, and doesn't filter them according to the request_tenant field, which I would consider the correct behavior. I'll show some code tomorrow. Can you confirm this being a bug? Or am I missing something? Thanks, Tsvi Sent from my phone db = DAL('sqlite://storage.sqlite') db._common_fields.append(Field('request_tenant',default=lambda: session.token,writable=False)) db.define_table('a',Field('name','string'),format='%(name)s') db.define_table('b',Field('a_name','reference a')) session.token = '1234' sample_list = [{'name':'John'},{'name':'Doe'}] db.a.bulk_insert(sample_list) session.token = '4567' sample_list = [{'name':'African'},{'name':'Swallow'}] db.a.bulk_insert(sample_list) form = SQLFORM(db.b) print form
Re: [web2py] Re: web2py 1.99.5 (please read)
Here some more information on the ticket it raises : (self=gluon.dal.PostgreSQLAdapter object, value=1, field_type='db.auth_user', blob_decode=True) Code listing 1498. 1499. 1500. 1501. 1502. 1503. 1504. 1505. 1506. 1507. return value elif field_type == 'blob' and not blob_decode: return value else: key = regex_type.match(field_type).group(0) return self.parsemap[key](value,field_type) def parse_reference(self, value, field_type): referee = field_type[10:].strip() if not '.' in referee: Variablesfield_type'db.auth_user'selfgluon.dal.PostgreSQLAdapter object self.parsemap{'blob': bound method PostgreSQLAdapter.parse_blob of gluon.dal.PostgreSQLAdapter object, 'boolean': bound method PostgreSQLAdapter.parse_boolean of gluon.dal.PostgreSQLAdapter object, 'date': bound method PostgreSQLAdapter.parse_date of gluon.dal.PostgreSQLAdapter object, 'datetime': bound method PostgreSQLAdapter.parse_datetime of gluon.dal.PostgreSQLAdapter object, 'decimal': bound method PostgreSQLAdapter.parse_decimal of gluon.dal.PostgreSQLAdapter object, 'double': bound method PostgreSQLAdapter.parse_double of gluon.dal.PostgreSQLAdapter object, 'id': bound method PostgreSQLAdapter.parse_id of gluon.dal.PostgreSQLAdapter object, 'integer': bound method PostgreSQLAdapter.parse_integer of gluon.dal.PostgreSQLAdapter object, 'list:integer': bound method PostgreSQLAdapter.parse_list_integers of gluon.dal.PostgreSQLAdapter object, 'list:reference': bound method PostgreSQLAdapter.parse_list_references of gluon.dal.PostgreSQLAdapter object, ...}key'db'value1 It comes form this line in user function of default.py controller that I change a bit : form = auth() Here what I am doing : def user(): ... form = auth() auth.settings.formstyle = 'table3cols' if request.args(0) == 'login': form[0][1][1].append(SPAN((A(forget_pwd_icon(),_href=URL(r=request,c='default',f='user',args=('request_reset_password'))), SPAN(T('Click on icon if you forgot your password...'))), _class='logintip')) return dict(form=form,layout='login_layout.html') elif request.args(0) == 'profile': return dict(form='you are not allowed (permission)',layout='layout.html') elif request.args(0) == 'request_reset_password': if not 'request_reset_password' in auth.settings.actions_disabled: return dict(form=auth(),layout='login_layout.html') else: return dict(form=form,layout='layout.html') return dict(form=form,layout='layout.html') But I bypass the index and user function from my app and I still get the error... I believe that it could come from the postgres adapter some how... If you remember I use 'myIdName','id' to use my own custom table id name and also redefine the sequence name since the default sequence name build up of postgres is different from the one of web2py... Hope it helps. What else (i mean which changes) could cause this problem? Thanks. Richard 2012/2/28 Massimo Di Pierro massimo.dipie...@gmail.com What triggers it? I need a little more info. On Feb 28, 3:22 pm, Richard Vézina ml.richard.vez...@gmail.com wrote: type 'exceptions.KeyError' 'db' With trunk and copied my app in application folder... Richard On Tue, Feb 28, 2012 at 4:01 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: No. If you have time test the debugger. That is a major piece of code that you will notice right away. Mariano can explain better than me. The other features have been reasonably tested. Massimo On Feb 28, 2:46 pm, szimszon szims...@gmail.com wrote: +1 Anyway it could be good to have some more hint about what the new features do. So we can easily test without to follow all conversation about features between versions :-o 2012. február 28., kedd 21:35:03 UTC+1 időpontban Anthony a következőt írta: We need to make the book editable again so some of us can start adding this stuff to the documentation. :-) On Tuesday, February 28, 2012 3:28:09 PM UTC-5, Massimo Di Pierro wrote: I am planning to release this tomorrow but you can test it today. ***Please help us test it today*** It is really important. There is a huge number of improvements and bug fixes. We should really call this web2py 2.0 but we prefer to wait before advertising some of the new features which are in but need more testing. List not in order of importance: - included remote debugger (thanks Mariano) - gluon/contrib/htmlmin.py for html minimization (thanks kerncece) - out of the box posgresql support with pg8000 diver included (thanks Mariano) - admin in Russian (Bulat), Japanese (Omi) and Slovenian (Robert Valentak) - db.table.field.like(...,case_sensitive=False) (thanks Floyd) - db.table.field.regexp(...) for sqlite
Re: [web2py] Re: web2py 1.99.5 (please read)
Forget to mention. I also try the welcome app with postgres with no problem. I create a use and can logon and logoff... Richard 2012/2/29 Richard Vézina ml.richard.vez...@gmail.com Here some more information on the ticket it raises : (self=gluon.dal.PostgreSQLAdapter object, value=1, field_type='db.auth_user', blob_decode=True) Code listing 1498. 1499. 1500. 1501. 1502. 1503. 1504. 1505. 1506. 1507. return value elif field_type == 'blob' and not blob_decode: return value else: key = regex_type.match(field_type).group(0) return self.parsemap[key](value,field_type) def parse_reference(self, value, field_type): referee = field_type[10:].strip() if not '.' in referee: Variables field_type 'db.auth_user' self gluon.dal.PostgreSQLAdapter object self.parsemap {'blob': bound method PostgreSQLAdapter.parse_blob of gluon.dal.PostgreSQLAdapter object, 'boolean': bound method PostgreSQLAdapter.parse_boolean of gluon.dal.PostgreSQLAdapter object, 'date': bound method PostgreSQLAdapter.parse_date of gluon.dal.PostgreSQLAdapter object, 'datetime': bound method PostgreSQLAdapter.parse_datetime of gluon.dal.PostgreSQLAdapter object, 'decimal': bound method PostgreSQLAdapter.parse_decimal of gluon.dal.PostgreSQLAdapter object, 'double': bound method PostgreSQLAdapter.parse_double of gluon.dal.PostgreSQLAdapter object, 'id': bound method PostgreSQLAdapter.parse_id of gluon.dal.PostgreSQLAdapter object, 'integer': bound method PostgreSQLAdapter.parse_integer of gluon.dal.PostgreSQLAdapter object, 'list:integer': bound method PostgreSQLAdapter.parse_list_integers of gluon.dal.PostgreSQLAdapter object, 'list:reference': bound method PostgreSQLAdapter.parse_list_references of gluon.dal.PostgreSQLAdapter object, ...} key 'db' value 1 It comes form this line in user function of default.py controller that I change a bit : form = auth() Here what I am doing : def user(): ... form = auth() auth.settings.formstyle = 'table3cols' if request.args(0) == 'login': form[0][1][1].append(SPAN((A(forget_pwd_icon(),_href=URL(r=request,c='default',f='user',args=('request_reset_password'))), SPAN(T('Click on icon if you forgot your password...'))), _class='logintip')) return dict(form=form,layout='login_layout.html') elif request.args(0) == 'profile': return dict(form='you are not allowed (permission)',layout='layout.html') elif request.args(0) == 'request_reset_password': if not 'request_reset_password' in auth.settings.actions_disabled: return dict(form=auth(),layout='login_layout.html') else: return dict(form=form,layout='layout.html') return dict(form=form,layout='layout.html') But I bypass the index and user function from my app and I still get the error... I believe that it could come from the postgres adapter some how... If you remember I use 'myIdName','id' to use my own custom table id name and also redefine the sequence name since the default sequence name build up of postgres is different from the one of web2py... Hope it helps. What else (i mean which changes) could cause this problem? Thanks. Richard 2012/2/28 Massimo Di Pierro massimo.dipie...@gmail.com What triggers it? I need a little more info. On Feb 28, 3:22 pm, Richard Vézina ml.richard.vez...@gmail.com wrote: type 'exceptions.KeyError' 'db' With trunk and copied my app in application folder... Richard On Tue, Feb 28, 2012 at 4:01 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: No. If you have time test the debugger. That is a major piece of code that you will notice right away. Mariano can explain better than me. The other features have been reasonably tested. Massimo On Feb 28, 2:46 pm, szimszon szims...@gmail.com wrote: +1 Anyway it could be good to have some more hint about what the new features do. So we can easily test without to follow all conversation about features between versions :-o 2012. február 28., kedd 21:35:03 UTC+1 időpontban Anthony a következőt írta: We need to make the book editable again so some of us can start adding this stuff to the documentation. :-) On Tuesday, February 28, 2012 3:28:09 PM UTC-5, Massimo Di Pierro wrote: I am planning to release this tomorrow but you can test it today. ***Please help us test it today*** It is really important. There is a huge number of improvements and bug fixes. We should really call this web2py 2.0 but we prefer to wait before advertising some of the new features which are in but need more testing. List not in order of importance: - included remote debugger (thanks Mariano) - gluon/contrib/htmlmin.py for html minimization (thanks kerncece) -
[web2py] Re: Database deadlocks with new scheduler
Thanks for the advice, Massimo. Yes, I am calling db.scheduler_task.insert() inside a controller. On the theory that it could do harm, I put a db.commit() immediately after the insert and that helped, some. Now I'm getting the scheduler exception in my worker process about a third as often, and when it occurs, I can clear the deadlock easier. Sometimes, I can just restart the worker process. Sometimes I have to user the MySQL client to stop the query (ie., mysql kill query 24843;) (I don't want it to sound like I really understand how to clear the deadlock. I'm just doing something I read about on stackoverflow.) I'd like to understand better how the deadlocks arise and what I can do to prevent them. Thanks. David On Feb 27, 11:11 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Do you do this in a controller? db.scheduler_task.insert(...) if not. Make sure you db.commit() immediately after. Would is solve the problem? On Feb 27, 9:14 pm, David Phillips david.phillips@gmail.com wrote: I am experiencing database deadlocks in a worker processes that is being scheduled by web2py's newscheduler. I'm using the latest web2py with Python 2.7.2 and MySQL (a recent release) on OS X 10.7.3. The worker does a lengthy calculation that I wanted to take off the http thread. Every time I get a certain action, I schedule the thread programmatically like this: db.scheduler_task.insert(application_name = 'geo', task_name = 'match_task', function_name = 'match_listings', vars = json.dumps(vars)) In my testing I execute this task about once every two seconds. It has failed in two separate tests after about an hour. I'm getting this traceback: File /Users/davidp/dev/python/web2py/gluon/shell.py, line 214, in run exec(python_code, _env) File string, line 1, in module File /Users/davidp/dev/python/web2py/gluon/scheduler.py, line 363, in loop MetaScheduler.loop(self) File /Users/davidp/dev/python/web2py/gluon/scheduler.py, line 255, in loop task = self.pop_task() File /Users/davidp/dev/python/web2py/gluon/scheduler.py, line 392, in pop_task grabbed.update(assigned_worker_name='',status=QUEUED) File /Users/davidp/dev/python/web2py/gluon/dal.py, line 6346, in update return self.db._adapter.update(tablename,self.query,fields) File /Users/davidp/dev/python/web2py/gluon/dal.py, line 1093, in update self.execute(sql) File /Users/davidp/dev/python/web2py/gluon/dal.py, line 1359, in execute return self.log_execute(*a, **b) File /Users/davidp/dev/python/web2py/gluon/dal.py, line 1353, in log_execute ret = self.cursor.execute(*a, **b) File /Users/davidp/dev/python/web2py/gluon/contrib/pymysql/ cursors.py, line 108, in execute self.errorhandler(self, exc, value) File /Users/davidp/dev/python/web2py/gluon/contrib/pymysql/ connections.py, line 184, in defaulterrorhandler raise errorclass, errorvalue InternalError: (1213, u'Deadlockfound when trying to get lock; try restarting transaction') When executed, the task does this SQL select: expr = '''SELECT *, ( 3959 * acos (cos (radians (%s)) * cos (radians (lat)) * cos (radians (lon) - radians (%s)) + sin (radians (%s)) * sin (radians (lat AS distance FROM users HAVING distance radius;''' % (point[0], point[1], point[0]) nearby_users = db.executesql(expr, as_dict = True) and then does a read to collect some statistics to track performance: num_listings = db (db.listings.id 0).count() During this time, I am receiving asynchronous http requests that insert, update and delete from this table (and another table, too). My MySQL client responds to a show engine innodb status; command this way: LATEST DETECTEDDEADLOCK 120227 20:38:16 *** (1) TRANSACTION: TRANSACTION 27AFF, ACTIVE 0 sec starting index read mysql tables in use 1, locked 1 LOCK WAIT 3 lock struct(s), heap size 376, 2 row lock(s), undo log entries 1 MySQL thread id 19816, OS thread handle 0x10c5db000, query id 1558959 localhost 127.0.0.1 root Updating UPDATE scheduler_task SET status='QUEUED',assigned_worker_name='' WHERE ((scheduler_task.assigned_worker_name = 'Mycroft.local#d600fcf2- a363-4870-bd24-1ad3694f6a62') AND (scheduler_task.status = 'ASSIGNED')) *** (1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 0 page no 3031 n bits 120 index `PRIMARY` of table `geo`.`scheduler_task` trx id 27AFF lock_mode X waiting Record lock, heap no 2 PHYSICAL RECORD: n_fields 20; compact format; info bits 0 0: len 4; hex 802c; asc ,;; 1: len 6; hex 00024db1; asc M ;; 2: len 7; hex 6a0d4c2f35; asc j L/5;; 3: len 3; hex 67656f; asc geo;; 4: len 10; hex 656d61696c207461736b; asc email task;; 5: len 4; hex 6d61696e; asc
[web2py] windows users? need help with a test...
Download the latest nightly build (just posted). Open welcome, edit a language file and save it. Does it work fine?
[web2py] Re: windows users? need help with a test...
Hi Massimo, Do you mean go to the following url and click update? http://localhost:8000/admin/default/edit_language/welcome/languages/es-es.py It saved without problems. Carlos On Wednesday, February 29, 2012 1:48:27 PM UTC-6, Massimo Di Pierro wrote: Download the latest nightly build (just posted). Open welcome, edit a language file and save it. Does it work fine?
[web2py] Re: windows users? need help with a test...
If you're asking whether admin successfully saves changes to a language file on Windows, it seems to be working for me using the latest trunk. Anthony On Wednesday, February 29, 2012 3:25:17 PM UTC-5, Carlos wrote: Hi Massimo, Do you mean go to the following url and click update? http://localhost:8000/admin/default/edit_language/welcome/languages/es-es.py It saved without problems. Carlos On Wednesday, February 29, 2012 1:48:27 PM UTC-6, Massimo Di Pierro wrote: Download the latest nightly build (just posted). Open welcome, edit a language file and save it. Does it work fine?
Re: [web2py] Computed field not working
You can't access valor_do_dolar from custo_em_real lambda computed since it is a computed field that get computed un submit... If you want to do that you will have to make a real function that get process on submit with form.process().accepted and the argument onsuccess or onvalidation See chapter 7 with both keyword here a link for the first keyword : http://web2py.com/books/default/chapter/29/7?search=onsuccess Richard On Wed, Feb 29, 2012 at 3:51 PM, Tito Garrido titogarr...@gmail.com wrote: Hi Folks, I am trying a simple example using sqlite: db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['valor_do_dolar']), Field('valor_total', compute=lambda vt: vt['custo_em_real']*vt['quantidade']) But both computed fields are always set as None... I am trying it from administrative database screen... Am I doing anything wrong? -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
Re: [web2py] Computed field not working
Nice Catch, but I have commented the last field to apply what you suggested and this also doesn't work: db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['valor_do_dolar']), ) On Wed, Feb 29, 2012 at 6:06 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: You can't access valor_do_dolar from custo_em_real lambda computed since it is a computed field that get computed un submit... If you want to do that you will have to make a real function that get process on submit with form.process().accepted and the argument onsuccess or onvalidation See chapter 7 with both keyword here a link for the first keyword : http://web2py.com/books/default/chapter/29/7?search=onsuccess Richard On Wed, Feb 29, 2012 at 3:51 PM, Tito Garrido titogarr...@gmail.comwrote: Hi Folks, I am trying a simple example using sqlite: db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['valor_do_dolar']), Field('valor_total', compute=lambda vt: vt['custo_em_real']*vt['quantidade']) But both computed fields are always set as None... I am trying it from administrative database screen... Am I doing anything wrong? -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
Re: [web2py] Computed field not working
You valor_do_dolar field is still a problem in the model down here... Since you can't or your lambda can't accès valor_do_dolar in that example. The field don't exist in the form so the key not exist so web2py return none and custo_em_dolar*none will return none I guest. try this : db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['* cotacao_do_dolar*']), ) And provide input data for both field and it should works, not like you want it to works, but you will make sure that it could works. Also, notice that if you set a field to writable and/or readable = False, they will not be in the form and not provide any input data to your lambda so it will failed. I don't see what you do in your controller here that why I notice you about that. It is a common pit fall into which I run often when set new computed field on existing table because I kind of filter the field I show to user with writable and readable = False often and forget about those rules. :) Richard On Wed, Feb 29, 2012 at 4:16 PM, Tito Garrido titogarr...@gmail.com wrote: Nice Catch, but I have commented the last field to apply what you suggested and this also doesn't work: db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['valor_do_dolar']), ) On Wed, Feb 29, 2012 at 6:06 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: You can't access valor_do_dolar from custo_em_real lambda computed since it is a computed field that get computed un submit... If you want to do that you will have to make a real function that get process on submit with form.process().accepted and the argument onsuccess or onvalidation See chapter 7 with both keyword here a link for the first keyword : http://web2py.com/books/default/chapter/29/7?search=onsuccess Richard On Wed, Feb 29, 2012 at 3:51 PM, Tito Garrido titogarr...@gmail.comwrote: Hi Folks, I am trying a simple example using sqlite: db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['valor_do_dolar']), Field('valor_total', compute=lambda vt: vt['custo_em_real']*vt['quantidade']) But both computed fields are always set as None... I am trying it from administrative database screen... Am I doing anything wrong? -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
[web2py] web2py Leaflet.js and firefox won't render map tiles
Leaflet http://leaflet.cloudmade.com, a javascript library for embedding maps, has a mysterious problem that only crops up when you host a page using leaflet on web2py and try to view it in firefox. Specifically, map tiles fail to be loaded. As far as I can tell, leaflet is working as it should, building the map and placing it in the div, and even retrieving the tiles and appropriate urls, but firefox resolutely fails to show the actual map tiles. Webkit based browsers don't have a problem, but firefox (and ie 10) can't seem to handle the combination of web2py and leaflet. Anyone wanting to replicate this issue can take the simple example from leaflet's documentation, an api key from cloudmade.com (free), and load the page from web2py. Note: Leaflet absolutely works when its hosted on a simple webserver (I tested it on IIS). I can provide a code sample if needed. Can anyone help me track down the problem?
[web2py] Re: windows users? need help with a test...
Great. This is what I needed to know as a the language load/dave functions were rewritten to avoid the concurrency problem. They use a trick to open the file in append mode and then seek(0) and truncate() instead of opening the file in write mode. I knew it works on Mac and Linux but I was not sure about windows. Thanks again. Massimo On Feb 29, 2:25 pm, Carlos carlosgali...@gmail.com wrote: Hi Massimo, Do you mean go to the following url and click update? http://localhost:8000/admin/default/edit_language/welcome/languages/e... It saved without problems. Carlos On Wednesday, February 29, 2012 1:48:27 PM UTC-6, Massimo Di Pierro wrote: Download the latest nightly build (just posted). Open welcome, edit a language file and save it. Does it work fine?
Re: [web2py] Computed field not working
Thanks a lot Richard! you were right! I have put the wrong field on the calculation! You are the best! Thank you! On Wed, Feb 29, 2012 at 6:25 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: You valor_do_dolar field is still a problem in the model down here... Since you can't or your lambda can't accès valor_do_dolar in that example. The field don't exist in the form so the key not exist so web2py return none and custo_em_dolar*none will return none I guest. try this : db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['* cotacao_do_dolar*']), ) And provide input data for both field and it should works, not like you want it to works, but you will make sure that it could works. Also, notice that if you set a field to writable and/or readable = False, they will not be in the form and not provide any input data to your lambda so it will failed. I don't see what you do in your controller here that why I notice you about that. It is a common pit fall into which I run often when set new computed field on existing table because I kind of filter the field I show to user with writable and readable = False often and forget about those rules. :) Richard On Wed, Feb 29, 2012 at 4:16 PM, Tito Garrido titogarr...@gmail.comwrote: Nice Catch, but I have commented the last field to apply what you suggested and this also doesn't work: db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['valor_do_dolar']), ) On Wed, Feb 29, 2012 at 6:06 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: You can't access valor_do_dolar from custo_em_real lambda computed since it is a computed field that get computed un submit... If you want to do that you will have to make a real function that get process on submit with form.process().accepted and the argument onsuccess or onvalidation See chapter 7 with both keyword here a link for the first keyword : http://web2py.com/books/default/chapter/29/7?search=onsuccess Richard On Wed, Feb 29, 2012 at 3:51 PM, Tito Garrido titogarr...@gmail.comwrote: Hi Folks, I am trying a simple example using sqlite: db.define_table('compra_produto', Field('compra', 'reference compra'), Field('produto','reference produto'), Field('quantidade','integer'), Field('custo_em_dolar','double'), Field('cotacao_do_dolar','double'), Field('custo_em_real', compute=lambda cr: cr['custo_em_dolar']*cr['valor_do_dolar']), Field('valor_total', compute=lambda vt: vt['custo_em_real']*vt['quantidade']) But both computed fields are always set as None... I am trying it from administrative database screen... Am I doing anything wrong? -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
[web2py] Re: problems refreshing component from link in svg image
Hi Anthony, Sorry for the delayed response. Adding window.parent did the trick. Thanks. Ian On Wednesday, February 22, 2012 8:38:14 PM UTC-5, Anthony wrote: Maybe try: top.web2py_component(/paideia/exploring/index.load,page) or window.parent.web2py_component(/paideia/exploring/index.load,page) Anthony On Wednesday, February 22, 2012 5:18:15 PM UTC-5, monotasker wrote: I'm using an svg image as a navigation map, with areas that can be clicked. I've got the interactivity working via an external javascript, but when I try to call web2py_component() I get an error telling me that web2py_component is not defined. I assumed that I could call it since this script is loaded after page load. I'm not sure where the problem lies, so here is how it's all set up: This is my js function to refresh the component (in static/js/svg_interactions.js): function go_there(evt){ var tobj = evt.currentTarget; var oname = tobj.getAttribute('id'); var the_url = /paideia/exploring/index.load/?loc= + oname web2py_component(/paideia/exploring/index.load,page) } This script is linked into the svg file (in the xml itself, as an immediate child of the svg element) like this: script type=text/javascript xlink:href=../js/svg_interactions.js / The function go_there() is called via the onclick attribute of any child entity in the svg file (onclick=go_there(evt)). The svg file is embedded in a view like this: embed src='{{=map_image}}' type='image/svg+xml' / Again, everything is working nicely except that svg_interactions.js doesn't seem to be aware of web2py_component(). Thanks, Ian
[web2py] Inheritance and composition of views
Hi all, Is it possible to include in a view, an inherited one? The docs aren't clear about this issue, so I don't know if the framework is supposed to allow this behaviour. I managed to make a simple example of what I'm trying to achieve: file 1: default/mytest.html (the view returned by the controller action) {{extend 'layout.html'}} pthis is mytest/p {{include 'component_a.html'}} file 2: component_template.html (the extended template) pthis is component_template/p {{block child}} {{include}} {{end}} file 3: component_a.html (the included template) {{extend 'component_template.html'}} {{block child}} pthis is component_a/p {{end}} Running mytest I was expecting: this is mytest this is component_template this is component_a but it outputs: this is mytest this is component_template Can anyone help? Thanks in advance Pedro
[web2py] Re: Inheritance and composition of views
Short answer no. Think of the page hierarchy as a tree. {{extend ...}} points up to a parent. {{include ...}} points down to a child. When your controller returns it calls a view and this one can move up (extend) and down (import) the tree. If you want to import X which extends Y before being imported, you need to collapse the new tree into a tree node. This means either you use ajax or your use {{=response.render()}} inside the importing view. I wound not go this way. Massimo On Feb 29, 4:06 pm, Pedro Pereira pedrompere...@gmail.com wrote: Hi all, Is it possible to include in a view, an inherited one? The docs aren't clear about this issue, so I don't know if the framework is supposed to allow this behaviour. I managed to make a simple example of what I'm trying to achieve: file 1: default/mytest.html (the view returned by the controller action) {{extend 'layout.html'}} pthis is mytest/p {{include 'component_a.html'}} file 2: component_template.html (the extended template) pthis is component_template/p {{block child}} {{include}} {{end}} file 3: component_a.html (the included template) {{extend 'component_template.html'}} {{block child}} pthis is component_a/p {{end}} Running mytest I was expecting: this is mytest this is component_template this is component_a but it outputs: this is mytest this is component_template Can anyone help? Thanks in advance Pedro
Re: [web2py] Re: Inheritance and composition of views
Understoodthanks a lot!! On Wed, Feb 29, 2012 at 22:18, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Short answer no. Think of the page hierarchy as a tree. {{extend ...}} points up to a parent. {{include ...}} points down to a child. When your controller returns it calls a view and this one can move up (extend) and down (import) the tree. If you want to import X which extends Y before being imported, you need to collapse the new tree into a tree node. This means either you use ajax or your use {{=response.render()}} inside the importing view. I wound not go this way. Massimo On Feb 29, 4:06 pm, Pedro Pereira pedrompere...@gmail.com wrote: Hi all, Is it possible to include in a view, an inherited one? The docs aren't clear about this issue, so I don't know if the framework is supposed to allow this behaviour. I managed to make a simple example of what I'm trying to achieve: file 1: default/mytest.html (the view returned by the controller action) {{extend 'layout.html'}} pthis is mytest/p {{include 'component_a.html'}} file 2: component_template.html (the extended template) pthis is component_template/p {{block child}} {{include}} {{end}} file 3: component_a.html (the included template) {{extend 'component_template.html'}} {{block child}} pthis is component_a/p {{end}} Running mytest I was expecting: this is mytest this is component_template this is component_a but it outputs: this is mytest this is component_template Can anyone help? Thanks in advance Pedro
Re: [web2py] Re: web2py 1.99.5 (please read)
I am not able to access to appadmin when I click the button database administration of any application in the admin application. mic Il giorno 29 febbraio 2012 20:31, Richard Vézina ml.richard.vez...@gmail.com ha scritto: Forget to mention. I also try the welcome app with postgres with no problem. I create a use and can logon and logoff... Richard 2012/2/29 Richard Vézina ml.richard.vez...@gmail.com Here some more information on the ticket it raises : (self=gluon.dal.PostgreSQLAdapter object, value=1, field_type='db.auth_user', blob_decode=True) Code listing 1498. 1499. 1500. 1501. 1502. 1503. 1504. 1505. 1506. 1507. return value elif field_type == 'blob' and not blob_decode: return value else: key = regex_type.match(field_type).group(0) return self.parsemap[key](value,field_type) def parse_reference(self, value, field_type): referee = field_type[10:].strip() if not '.' in referee: Variables field_type 'db.auth_user' self gluon.dal.PostgreSQLAdapter object self.parsemap {'blob': bound method PostgreSQLAdapter.parse_blob of gluon.dal.PostgreSQLAdapter object, 'boolean': bound method PostgreSQLAdapter.parse_boolean of gluon.dal.PostgreSQLAdapter object, 'date': bound method PostgreSQLAdapter.parse_date of gluon.dal.PostgreSQLAdapter object, 'datetime': bound method PostgreSQLAdapter.parse_datetime of gluon.dal.PostgreSQLAdapter object, 'decimal': bound method PostgreSQLAdapter.parse_decimal of gluon.dal.PostgreSQLAdapter object, 'double': bound method PostgreSQLAdapter.parse_double of gluon.dal.PostgreSQLAdapter object, 'id': bound method PostgreSQLAdapter.parse_id of gluon.dal.PostgreSQLAdapter object, 'integer': bound method PostgreSQLAdapter.parse_integer of gluon.dal.PostgreSQLAdapter object, 'list:integer': bound method PostgreSQLAdapter.parse_list_integers of gluon.dal.PostgreSQLAdapter object, 'list:reference': bound method PostgreSQLAdapter.parse_list_references of gluon.dal.PostgreSQLAdapter object, ...} key 'db' value 1 It comes form this line in user function of default.py controller that I change a bit : form = auth() Here what I am doing : def user(): ... form = auth() auth.settings.formstyle = 'table3cols' if request.args(0) == 'login': form[0][1][1].append(SPAN((A(forget_pwd_icon(),_href=URL(r=request,c='default',f='user',args=('request_reset_password'))), SPAN(T('Click on icon if you forgot your password...'))), _class='logintip')) return dict(form=form,layout='login_layout.html') elif request.args(0) == 'profile': return dict(form='you are not allowed (permission)',layout='layout.html') elif request.args(0) == 'request_reset_password': if not 'request_reset_password' in auth.settings.actions_disabled: return dict(form=auth(),layout='login_layout.html') else: return dict(form=form,layout='layout.html') return dict(form=form,layout='layout.html') But I bypass the index and user function from my app and I still get the error... I believe that it could come from the postgres adapter some how... If you remember I use 'myIdName','id' to use my own custom table id name and also redefine the sequence name since the default sequence name build up of postgres is different from the one of web2py... Hope it helps. What else (i mean which changes) could cause this problem? Thanks. Richard 2012/2/28 Massimo Di Pierro massimo.dipie...@gmail.com What triggers it? I need a little more info. On Feb 28, 3:22 pm, Richard Vézina ml.richard.vez...@gmail.com wrote: type 'exceptions.KeyError' 'db' With trunk and copied my app in application folder... Richard On Tue, Feb 28, 2012 at 4:01 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: No. If you have time test the debugger. That is a major piece of code that you will notice right away. Mariano can explain better than me. The other features have been reasonably tested. Massimo On Feb 28, 2:46 pm, szimszon szims...@gmail.com wrote: +1 Anyway it could be good to have some more hint about what the new features do. So we can easily test without to follow all conversation about features between versions :-o 2012. február 28., kedd 21:35:03 UTC+1 időpontban Anthony a következőt írta: We need to make the book editable again so some of us can start adding this stuff to the documentation. :-) On Tuesday, February 28, 2012 3:28:09 PM UTC-5, Massimo Di Pierro wrote: I am planning to release this tomorrow but you can test it today. ***Please help us test it today*** It is really important. There is a huge number of improvements and bug fixes. We should really call this web2py 2.0 but we prefer to wait before
[web2py] Re: Multiple auth - Good practice?
Ok, thanks. So I have an idea involving groups. I edited my auth_user table, I did that with no problem but I cant seem to link it to another table so I get a drop down in one of the fields: Here is my model (notice IS_IN_DB): ##Aditional table to support auth_user db.define_table('department', Field('name'), Field('abbreviation'), Field('committee')) ##Additional auth_user fields auth.settings.extra_fields['auth_user']= [Field('company'), Field('department',db.department)] db.auth_user.department.requires=IS_IN_DB(db,'department.id','% (name)s') The error, cant find auth_user. Thanks On Feb 28, 5:40 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You can have two auth objects and you can swicth between them using for example a session variable or a parameter in the URL. Yet is is going to be a mess. I suggest instead you use one auth table and user roles and permissions to decide who can do what. massimo On Feb 28, 4:12 pm, greenpoise danel.sega...@gmail.com wrote: Sorry, I pressed enter without being finished: My second option 2. Build a table called employee that uses only one auth table. Either way I am stuck on how to do this.. First would like to know which is a good practice and second, how could I accomplish this?? Thanks dan On Feb 28, 2:10 pm, greenpoise danel.sega...@gmail.com wrote: I have been searching in this group for a way of implementing two authentication within one application. My idea is to have Auth table managed by an administrator. However, I want to give the flexibility to added users to add their own employees and the employees being able to log into the application. My question is, is this a good practice? would it work?? I can think of two options: 1. Having a second auth table and login process separate from the main auth table
[web2py] Getting user timezone
Does web2py have any built-in mechanism for establishing the timezone of a user?
Re: [web2py] Thumbnails
I like the module approach. I just put the function in my model file like this: db.item.image_thumb.compute = lambda r: resize_image(r['image'], (150,130), 'thumb') db.item.image_display.compute = lambda r: resize_image(r['image'], (320,320), 'display') def resize_image(image, size, path, rotate=0): if image: try: img = Image.open('%sstatic/uploads/%s' % (request.folder, image)) img = img.convert(RGB) img.thumbnail(size, Image.ANTIALIAS) img = img.rotate(rotate) root, ext = os.path.splitext(image) filename = '%s_%s%s' %(root, path, ext) img.save('%sstatic/uploads/%s' % (request.folder, filename)) return filename except Exception, e: return e else: return None
Re: [web2py] Thumbnails
Oops, make sure to import PIL: from PIL import Image
Re: [web2py] Re: Inheritance and composition of views
Dont know if it helps, but note that you can enclose HTML as a function. views/my_html_functions.html {{def my_html_block(args):}} {{if args.:}} tag/tag {{pass}} {{=DIV(UL(LI()))}} tag/tag tag/tag tag/tag {{return}} views/anyfile.html {{extend layout.html}} {{include my_html_functions.html}} div {{my_html_blog(args)}} /div Note that when calling that function you do not need to use {{=}}
[web2py] Re: Deleting upload files -- possible bug?
@Anthony: Thanks for such a thorough response. I'm sorry I didn't mention for Question 2 that I was deleting the files myself using a method almost identical to the one you presented here. I was just wondering if there was a built-in way to do this more efficiently (less coding). Apparently not, which is OK, since the method presented is pretty simple. On Question 1 - I continue to investigate and have the following to report. First, I discovered the following exception: TransactionRollbackError: deadlock detected\nDETAIL: Process 6208 waits for ShareLock on transaction 29974; blocked by process 8700.\nProcess 8700 waits for ShareLock on transaction 29973; blocked by process 6208.\nHINT: See server log for query details.\nCONTEXT: SQL statement DELETE FROM ONLY public.my_table WHERE $1 OPERATOR(pg_catalog.=) my_file_id\n This is probably caused by doing a bunch of deletes without a db.commit(). I placed a db.commit() immediately following each delete, and now some of the files are getting deleted, but not all. The static/ data/test.name/??/*.txt files are getting deleted. However the uploads/ test.image/??/*.jpg files are *NOT* getting deleted. So queueing up too many deletes without a db.commit() is at least partially the culprit. Does that make sense? Further testing - I then tried deleting the test record from within the web2py admin application and both files are getting deleted as expected. So then I tried something else ... First, some additional info. There is another table with a Field that refers to this test table and has an ondelete='CASCADE' parameter set. From within the web2py admin IDE, if I delete the other table first, the test table is not deleted as expected. If I then delete the test table, the static/data/??/*.txt files get deleted but the uploads/ test.image/??/*.jpg files do not. So perhaps the autodelete=True is a red herring. The problem may be with ondelete='CASCADE' pointing to a record with a field with autodelete=True. I hope this helps. This may, indeed, be a bug. Any thoughts?
[web2py] Re: Getting user timezone
I don't think you can reliably get it from the server side (there are services to infer it from IP address, but not completely reliable). You probably have to do it via Javascript in the browser: https://bitbucket.org/pellepim/jstimezonedetect. Anthony On Wednesday, February 29, 2012 7:13:21 PM UTC-5, Yarin wrote: Does web2py have any built-in mechanism for establishing the timezone of a user?
[web2py] Re: web2py Leaflet.js and firefox won't render map tiles
Is Leaflet just client side Javascript? Just to make sure nothing in web2py_ajax.html (and web2py.js) is interfering, what happens if you don't include web2py_ajax.html in your layout (assuming it is now included)? Also, are you using web2py templates to generate any of the Leaflet related JS or HTML, or is that fixed? If the former, maybe your template code isn't generating the proper Leaflet output (in which case, we'll need to see some code to help). Anthony On Wednesday, February 29, 2012 4:00:07 PM UTC-5, ender wrote: Leaflet http://leaflet.cloudmade.com, a javascript library for embedding maps, has a mysterious problem that only crops up when you host a page using leaflet on web2py and try to view it in firefox. Specifically, map tiles fail to be loaded. As far as I can tell, leaflet is working as it should, building the map and placing it in the div, and even retrieving the tiles and appropriate urls, but firefox resolutely fails to show the actual map tiles. Webkit based browsers don't have a problem, but firefox (and ie 10) can't seem to handle the combination of web2py and leaflet. Anyone wanting to replicate this issue can take the simple example from leaflet's documentation, an api key from cloudmade.com (free), and load the page from web2py. Note: Leaflet absolutely works when its hosted on a simple webserver (I tested it on IIS). I can provide a code sample if needed. Can anyone help me track down the problem?
[web2py] Re: web2py Leaflet.js and firefox won't render map tiles
I suppose it could also be a CSS problem, so you might remove web2py.css and skeleton.css as well, just to see if that's the issue. On Wednesday, February 29, 2012 9:40:19 PM UTC-5, Anthony wrote: Is Leaflet just client side Javascript? Just to make sure nothing in web2py_ajax.html (and web2py.js) is interfering, what happens if you don't include web2py_ajax.html in your layout (assuming it is now included)? Also, are you using web2py templates to generate any of the Leaflet related JS or HTML, or is that fixed? If the former, maybe your template code isn't generating the proper Leaflet output (in which case, we'll need to see some code to help). Anthony On Wednesday, February 29, 2012 4:00:07 PM UTC-5, ender wrote: Leaflet http://leaflet.cloudmade.com, a javascript library for embedding maps, has a mysterious problem that only crops up when you host a page using leaflet on web2py and try to view it in firefox. Specifically, map tiles fail to be loaded. As far as I can tell, leaflet is working as it should, building the map and placing it in the div, and even retrieving the tiles and appropriate urls, but firefox resolutely fails to show the actual map tiles. Webkit based browsers don't have a problem, but firefox (and ie 10) can't seem to handle the combination of web2py and leaflet. Anyone wanting to replicate this issue can take the simple example from leaflet's documentation, an api key from cloudmade.com (free), and load the page from web2py. Note: Leaflet absolutely works when its hosted on a simple webserver (I tested it on IIS). I can provide a code sample if needed. Can anyone help me track down the problem?
Re: [web2py] Re: cron setup
Luciano i removed the one * before the applications and tryed than i got the following error :- OperationalError: unable to open database file Traceback (most recent call last): File /home/tls-sanjeet/Desktop/test/web2py/gluon/restricted.py, line 204, in restricted exec ccode in environment File applications/welcome/models/db.py, line 14, in module db = DAL('sqlite://storage.sqlite') File /home/tls-sanjeet/Desktop/test/web2py/gluon/dal.py, line 4749, in __init__ raise RuntimeError, Failure to connect, tried %d times:\n%s % (attempts, tb) RuntimeError: Failure to connect, tried 5 times: Traceback (most recent call last): File /home/tls-sanjeet/Desktop/test/web2py/gluon/dal.py, line 4736, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File /home/tls-sanjeet/Desktop/test/web2py/gluon/dal.py, line 1655, in __init__ self.pool_connection(connect) File /home/tls-sanjeet/Desktop/test/web2py/gluon/dal.py, line 444, in pool_connection self.connection = f() File /home/tls-sanjeet/Desktop/test/web2py/gluon/dal.py, line 1654, in connect return self.driver.Connection(dbpath, **driver_args) OperationalError: unable to open database file On Wednesday, February 29, 2012 6:39:22 PM UTC+5:30, lucmult wrote: On Wed, Feb 29, 2012 at 11:10 PM, Sanjeet Kumar sanjeet@gmail.comwrote: I have the following code in my crontab :- 0-59/1****root **applications/welcome/cron/test.py put just 1 * before applications/ [], -- Luciano Pacheco blog.lucmult.com.br
[web2py] Re: Web2py and SSLH
It just forwards the connection like a reverse proxy, so no MITM is caused. Why would I need to completely disable session cookies? Anyway... I was thinking about this more, and I remembered that the current scaffolding app's method of preventing security breaches through generic views is by disabling generic views unless you are on localhost (see line 27 of models/db.py in version 1.99.4). Since everything on SSL appears to be coming from localhost while using SSLH, I should disable generic patterns completely. On Monday, February 27, 2012 8:41:30 AM UTC-5, Ross Peoples wrote: I would be interested to see if SSH can actually be forwarded without triggering a main-in-the-middle error. I'm not sure on the first question, but I would guess that you would want to disable everything except your app. At the bottom of the db.py model, just put session.forget(request). This will still create cookies, I think but will not actually use them. Not sure on this one. Maybe someone else has a better answer for turning cookies off completely. In your model, I would also disable anything you don't need: db, mail, auth, etc. On Sunday, February 26, 2012 1:09:21 PM UTC-5, t13one wrote: I'm thinking about setting up SSLH on my personal server. From http://freecode.com/projects/sslh: sslh accepts HTTPS, SSH, OpenVPN, tinc, and XMPP connections on the same port. This makes it possible to connect to any of these servers on port 443 (e.g., from inside a corporate firewall, which almost never blocks port 443) while still serving HTTPS on that port. In short summary (and to my limited understanding), SSLH works by forwarding the connection from the sslh daemon to either the ssh server or the web-server (among other options). This means all SSL connections will ultimately appear to be connecting to apache/web2py via 127.0.0.1. Are there any security concerns with this? Should I disable admin and appadmin completely? How are session cookies affected? Would any other functionality be affected? On Sunday, February 26, 2012 1:09:21 PM UTC-5, t13one wrote: I'm thinking about setting up SSLH on my personal server. From http://freecode.com/projects/sslh: sslh accepts HTTPS, SSH, OpenVPN, tinc, and XMPP connections on the same port. This makes it possible to connect to any of these servers on port 443 (e.g., from inside a corporate firewall, which almost never blocks port 443) while still serving HTTPS on that port. In short summary (and to my limited understanding), SSLH works by forwarding the connection from the sslh daemon to either the ssh server or the web-server (among other options). This means all SSL connections will ultimately appear to be connecting to apache/web2py via 127.0.0.1. Are there any security concerns with this? Should I disable admin and appadmin completely? How are session cookies affected? Would any other functionality be affected?
[web2py] Web2py basic setup for Windows
Hi Friends, I am fairly new to Web2py and I need help. I use windows. Originally I set up Web2py on my computer using the binaries and I was able to get the Web2py server come up and do some very basic tests using the Web interface. However, I was not able to run the examples that are provided in the Web2py documentation using the intepreter. This led me to ask this group and I was advised that to do that I should install the Web2py code version and then use the command line invocation like this Python web2py.py and other command line arguments So I uninstalled the Web2py binary installation and installed the Web2py code version. However, now I am not sure how the server and web interface will start. I tried invoking Python like this from the windows prompt C:\Python web2py.py but that did not work as it could not fne web2py.py so I changed it to include the path to web2py.py like this C:\Python C:\web2py\web2py.py This worked somewhat but I now got an error which implied that import gluon was not working. So I then added an environment variable PYTHONPATH as follows: PYTHONPATH C:\web2py;C:\web2py\gluon With this change the C:\Phthon C:\web2py\web2py.py went further but I am now getting an error which says Traceback (most recent call last): File web2py.py, line 16, in module import gluon.widget File C:\web2py\gluon\__init__.py, line 15, in module from globals import current File C:\web2py\gluon\globals.py, line 139 except TypeError, e: ^ SyntaxError: invalid syntax Can you please help with how to overcome this error. I will be very grateful. Thanks
[web2py] Re: web2py 1.99.5 (please read)
I'm trying to test the Teradata DAL change, but getting errors, I'm backtracking to test on SQL Server for creating Foreign Key relationships. Never tried this before now so I'm not sure if it worked before on SQL Server: dbSQL.define_table('Andrew_2py_PK', Field('Field1', 'string', length=10), Field('Field2'), format='%(Field1)s', primarykey = ['Field1'], migrate=True) dbSQL.define_table('Andrew_2py_PK_Child', Field('Parent', dbSQL.Andrew_2py_PK), Field('ChildField2'), format='%(ChildField2)s', primarykey = ['ChildField2'], migrate=True) getting the following : File D:\Mercurial\web2py_Local\gluon\dal.py, line 6785, in __getattr__ return self[key] File D:\Mercurial\web2py_Local\gluon\dal.py, line 6725, in __getitem__ return dict.__getitem__(self, str(key)) KeyError: '_id' I found that at line 6576: elif isinstance(field, Table): evaluates to False for my FK column, which I expected to be True. I noticed that the book's DAL section doesn't mention references anymore references aren't working for references (yet), but they didn't work before either.
[web2py] Re: web2py 1.99.5 (please read)
P.S. Ignore the comment about the book. It's there ?? :(
[web2py] Re: web2py 1.99.5 (please read)
Sorry, one more. The last line should have read: References aren't working for Teradata (yet), but they didn't work before either.
[web2py] Re: Obtaining URL to image blob in GAE
@Anthony BrendanC: Thank you both for your code snippets! I've got it working now :). It's loading the image from a blob field in GAE's DB. @howesc: Can you possibly expand on how you modified your code to work with the blob store? That's something I'm also interested at looking into (would save lots of instance hours if every avatar lookup wasn't spinning up the app!). Thanks!
[web2py] Add the drop-down in plugin_instant_admin for best searching
How can i implement the drop-down in plugin_instant_admin for best searching
[web2py] My site on powered by web2py
Hello, My site fit trainer online URL is wrong making it impossible to get to: http://http//www.fittraineronline.com there should be only one http:// http://web2py.com/poweredby -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Web2py basic setup for Windows
Are you running Python 3? Note, the standard web2py is only compatible with Python 2.5 to 2.7 (though there is a Python 3 compatible branch). Note, you can simply create a shortcut to your web2py.py file on your desktop and click it to start the web2py server. Anthony On Wednesday, February 29, 2012 11:46:25 PM UTC-5, Alok wrote: Hi Friends, I am fairly new to Web2py and I need help. I use windows. Originally I set up Web2py on my computer using the binaries and I was able to get the Web2py server come up and do some very basic tests using the Web interface. However, I was not able to run the examples that are provided in the Web2py documentation using the intepreter. This led me to ask this group and I was advised that to do that I should install the Web2py code version and then use the command line invocation like this Python web2py.py and other command line arguments So I uninstalled the Web2py binary installation and installed the Web2py code version. However, now I am not sure how the server and web interface will start. I tried invoking Python like this from the windows prompt C:\Python web2py.py but that did not work as it could not fne web2py.py so I changed it to include the path to web2py.py like this C:\Python C:\web2py\web2py.py This worked somewhat but I now got an error which implied that import gluon was not working. So I then added an environment variable PYTHONPATH as follows: PYTHONPATH C:\web2py;C:\web2py\gluon With this change the C:\Phthon C:\web2py\web2py.py went further but I am now getting an error which says Traceback (most recent call last): File web2py.py, line 16, in module import gluon.widget File C:\web2py\gluon\__init__.py, line 15, in module from globals import current File C:\web2py\gluon\globals.py, line 139 except TypeError, e: ^ SyntaxError: invalid syntax Can you please help with how to overcome this error. I will be very grateful. Thanks
[web2py] Re: My site on powered by web2py
Sorry. Fixed. On Thursday, March 1, 2012 12:35:22 AM UTC-5, Detectedstealth wrote: Hello, My site fit trainer online URL is wrong making it impossible to get to: http://http//www.fittraineronline.com there should be only one http:// http://web2py.com/poweredby -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Re: My site on powered by web2py
Thanks, Here is the other site I have been busting my tail on: http://176.34.12.39we are now testing all the functionality and adding a few things before it is moved over to youadworld.com domain. On Wed, Feb 29, 2012 at 9:45 PM, Anthony abasta...@gmail.com wrote: Sorry. Fixed. On Thursday, March 1, 2012 12:35:22 AM UTC-5, Detectedstealth wrote: Hello, My site fit trainer online URL is wrong making it impossible to get to: http://http//www.**fittraineronline.comhttp://http//www.fittraineronline.comthere should be only one http:// http://web2py.com/poweredby -- -- Regards, Bruce Wade http://ca.linkedin.com/in/**brucelwadehttp://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.**fitnessfriendsfinder.comhttp://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Re: My site on powered by web2py
Cool. Let us know when it's ready and we'll post on the poweredby list. :-) On Thursday, March 1, 2012 12:47:24 AM UTC-5, Detectedstealth wrote: Thanks, Here is the other site I have been busting my tail on: http://176.34.12.39we are now testing all the functionality and adding a few things before it is moved over to youadworld.com domain. On Wed, Feb 29, 2012 at 9:45 PM, Anthony abasta...@gmail.com wrote: Sorry. Fixed. On Thursday, March 1, 2012 12:35:22 AM UTC-5, Detectedstealth wrote: Hello, My site fit trainer online URL is wrong making it impossible to get to: http://http//www.**fittraineronline.comhttp://http//www.fittraineronline.comthere should be only one http:// http://web2py.com/poweredby -- -- Regards, Bruce Wade http://ca.linkedin.com/in/**brucelwadehttp://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.**fitnessfriendsfinder.comhttp://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Connecting to Mysql on MAMP?
Does anyone connect to a Mysql database running under MAMP? My web2py is running on MacOS Python, not MAMP. I'm getting: OperationalError: (2003, Can't connect to MySQL server on 'localhost' (61)) One thing I had to do is when running Navicat or SequelPro (db mgmt client app) I needed to specify a different path to the socket file: /Applications/MAMP/tmp/mysql/mysql.sock Maybe I need to do that here? But how?
Re: [web2py] db.Table in appadmin when used in a module
On 29 February 2012 16:28, Bruce Wade bruce.w...@gmail.com wrote: Is there any reason you have a extra comma in the __init__ method? def __init__(self, db*,*): Well spotted. No. It was a typo. I have removed it now, but that did not change the behaviour of appadmin. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] db.Table in appadmin when used in a module
Have you tried setting: def __init__(self, db): self.signature = current.akb_signature_uuid then using self.signature? On Wed, Feb 29, 2012 at 10:21 PM, Johann Spies johann.sp...@gmail.comwrote: On 29 February 2012 16:28, Bruce Wade bruce.w...@gmail.com wrote: Is there any reason you have a extra comma in the __init__ method? def __init__(self, db*,*): Well spotted. No. It was a typo. I have removed it now, but that did not change the behaviour of appadmin. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Re: smartgrid query on 2 or more tables
On 29 February 2012 16:44, Roderick roderick.m...@gmail.com wrote: Thanks Johann! 1. Can this be done with smartgrid? Not in a similar way. You can read more about that in http://www.web2py.com/books/default/chapter/29/7?search=smartgrid#SQLFORM.grid-and-SQLFORM.smartgrid-%28experimental%29 2. Can you give me an example of a dynamic query (e.g. what users would type into the search field)? (for grid or smartgrid). Here is one built with the query button on one of my grids: akb_articles.title contains water and akb_articles.pubyear 1990 and akb_articles.pubyear = 2010 Experiment for yourself and explore the options. There is also a slice with examples on using SQLFORM.grid at http://www.web2pyslices.com/slices/take_slice/148 Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: windows users? need help with a test...
I am able to run the test fine on Win7(32bit), IE9 - Even my sample application ran fine - I am using web2py nightly build. Thanks, Rahul D On Mar 1, 2:34 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Great. This is what I needed to know as a the language load/dave functions were rewritten to avoid the concurrency problem. They use a trick to open the file in append mode and then seek(0) and truncate() instead of opening the file in write mode. I knew it works on Mac and Linux but I was not sure about windows. Thanks again. Massimo On Feb 29, 2:25 pm, Carlos carlosgali...@gmail.com wrote: Hi Massimo, Do you mean go to the following url and click update? http://localhost:8000/admin/default/edit_language/welcome/languages/e... It saved without problems. Carlos On Wednesday, February 29, 2012 1:48:27 PM UTC-6, Massimo Di Pierro wrote: Download the latest nightly build (just posted). Open welcome, edit a language file and save it. Does it work fine?
Re: [web2py] db.Table in appadmin when used in a module
On 1 March 2012 08:26, Bruce Wade bruce.w...@gmail.com wrote: Have you tried setting: def __init__(self, db): self.signature = current.akb_signature_uuid then using self.signature? Yes I had something similar and for some reason which I do not understand the code complained: AttributeError: 'Inst' object has no attribute 'signature' Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)