[web2py] Re: Sharing a database between apps
You need to specify the full path to the database file either relatively (sqlite://../../foo/bar/storage.sqlite) or absolutely (sqlite:///path/to/web2py/application/databases) you may want to use the os.path methods for this but either way should work for you On Sunday, November 25, 2012 4:27:17 PM UTC-6, pumplerod wrote: Sorry, I'm a little unclear on the manual explanation. as an example, given app1 and app2 I want to have app2 share the database I have built in app1 So do I change the app2/models/db.py file to show: db = DAL('sqlite://storage.sqlite',migrate='false') ? and include all other myModel.py files in app2/models directory as well? if the database is in app1/databases/ how does app2 know how to find the correct database file? --
[web2py] Multiple like clauses
I have a function which takes a list of prefixes the data from a select can start with. The list is of unknown size. I found that the contains function (db.mytable.myfield.contains('value')) can take a list instead of 'value'. When I try this with the startswith function ( db.mytable.myfield.contains('value')) I get an error. Is there any way I can get similar behaviour to contains but with startswith without moding web2py? Best regards, Joel --
[web2py] Re: web2py in Web Project
I'm also seeing similar problems : web2py (2.0.8) on webfaction, using dataTables plugin I started seeing 502 gateway errors Was the following problem resolved ? -Mandar On Friday, April 15, 2011 8:55:56 PM UTC+5:30, contatog...@gmail.com wrote: Hello, As I said before, I believe a system and stayed in webfaction.com. When I create theapplication there, they already have a script to download the web2py and prepare itwith Apache. But those weeks while using the system it gives the following error: 502 - Bad Gateway Reported that they were using too much memory, so why the server goes down . Onlyhas 2 to 4 users accessing the system, and specifically access a list of records thathave a total of 2000, and is paged using the plugin called jQuery Javascript DataTable. How do I use the MySQL database, I checked that was not using commit, andinsert after the queries, insertions and data edits. Still continued with the error. I askeveryone's help on this, because I will develop another web application, and I'mtraumatized about what happened and wanted to use the web2py for this project. What should I do when I play in production? What best practices should I play in the project toavoid this memory leaks with Apache and avoid excessive use of memory in queriesto the database? _ *Gilson Filho* *Web Developer http://gilsondev.com* --
[web2py] Re: Multiple like clauses
you need to build the query dinamically queries = [] for segment in mylist: queries.append(db.mytable.myfield.startswith(segment)) query = reduce(lambda a,b:(a|b),queries) results = db(query).select() Il giorno lunedì 26 novembre 2012 12:58:29 UTC+1, Joel Samuelsson ha scritto: I have a function which takes a list of prefixes the data from a select can start with. The list is of unknown size. I found that the contains function (db.mytable.myfield.contains('value')) can take a list instead of 'value'. When I try this with the startswith function ( db.mytable.myfield.contains('value')) I get an error. Is there any way I can get similar behaviour to contains but with startswith without moding web2py? Best regards, Joel --
Re: [web2py] Re: we should support this in DAL
I think DAL has nothing to do with Mongo. It is much easier to use only PyMongo API. What we really need is a Rows factory it shoul take arbitrary data format (can have a scheme) and will give us back a Rows object. Also it should have some event binders to update, delete, insert... So programmers will do this: mydata = pymongo.whatever() # pymongo dict like objects rows = gluon.RowsFactory(mydata, scheme=myscheme, updater=lambda, inserter=lambda, deleter=lambda) now we should have a Rows object and it could be used for grid, forms etc... The problem is that it can take long time to convert things in to Rows. So the best should be a dict + events based Form, grid and other controls designed specifically for these cases. Bruno Rocha http://rochacbruno.com.br mobile Em 26/11/2012 04:06, Mark Kirkwood mark.kirkw...@gmail.com escreveu: I am wondering if there are some deeper issues getting NoSQL support in Web2py - for instance the model part seems pretty tied into relational ideas (e.g db.define_table and ..references db.dog etc). This design works really well and insulates developers from much of the fiddlyness of dealing directly with relation db's quirks, but the ideas themselves are clearly relational. The other big DAL issue would be joins..but I guess integration with GAE has covered that to some extent (tho it looks like GAE can kinda fake a join with referenced properties...might be able to do something like that with Mongo, but not for all other NoSQLs). On Wednesday, November 21, 2012 11:58:35 PM UTC+13, Niphlod wrote: that is exactly the explanation of the term experimental. The problem as always is that if noone starts to test it, it will be in this way forever. On Tuesday, November 20, 2012 11:25:59 PM UTC+1, Simon Ashley wrote: The bottom line seems to be that we/ others need to start to use nosql engines to sort the issues. My guess is that, currently, critical mass is not present to rely on it for production sites. -- --
Re: [web2py] Database table prefix
I guess that nobody has ever had a need for this and that there is not really a solution for it? Regards, Chris On Friday, November 23, 2012 9:09:24 PM UTC+1, Chr_M wrote: That, but even the same app using different tables in the same db (but for different cliënts)... Regards, Chris On Friday, November 23, 2012 7:00:28 PM UTC+1, Richard wrote: Why exactly you change prefix? Installing differents apps dbs in the same db? Richard On Fri, Nov 23, 2012 at 10:57 AM, Chr_M chr@gmail.com wrote: Hi, I am new to web2py and am migrating an application to web2py. All the tables have a prefix that changes for the different deployments of the application. Is there a way in web2py to have a prefix for all the tables in the database that I can change easely for different deployments? At this time I use a PREFIX = 'prefix_' constant and define tables with db.define_table(PREFIX + 'table_name', etc... but this is becoming a bit complicated when defining requirements etc. Maybe there is an easier solution? Thanks in advance. Regards, Chris -- --
Re: [web2py] Database table prefix
Do you have a proposal for how an easier implementation should work? Also, rather than separate tables for different clients, have you considered either multi-tenancyhttp://web2py.com/books/default/chapter/29/06#Common-fields-and-multi-tenancyor just using separate databases (in the latter case, you could just define the DAL connection string dynamically to refer to the appropriate database)? Anthony On Monday, November 26, 2012 10:09:18 AM UTC-5, Chr_M wrote: I guess that nobody has ever had a need for this and that there is not really a solution for it? Regards, Chris On Friday, November 23, 2012 9:09:24 PM UTC+1, Chr_M wrote: That, but even the same app using different tables in the same db (but for different cliënts)... Regards, Chris On Friday, November 23, 2012 7:00:28 PM UTC+1, Richard wrote: Why exactly you change prefix? Installing differents apps dbs in the same db? Richard On Fri, Nov 23, 2012 at 10:57 AM, Chr_M chr@gmail.com wrote: Hi, I am new to web2py and am migrating an application to web2py. All the tables have a prefix that changes for the different deployments of the application. Is there a way in web2py to have a prefix for all the tables in the database that I can change easely for different deployments? At this time I use a PREFIX = 'prefix_' constant and define tables with db.define_table(PREFIX + 'table_name', etc... but this is becoming a bit complicated when defining requirements etc. Maybe there is an easier solution? Thanks in advance. Regards, Chris -- --
[web2py] common_filter not working?
#!/usr/bin/env python # export PYTHONPATH=.../web2py from gluon import DAL, Field def def_tables(db): p2 = db.define_table('p2', Field('name', 'string'), Field('is_active', 'boolean', default=True), common_filter = lambda q: db.p2.is_active==True) def get_db(): return DAL('sqlite://storage.sqlite') def get_db_with_schema(): db = get_db() def_tables(db) return db def db_ops(db): db.p2.truncate() db.p2.insert(name='Alice') db.p2.insert(name='Bob') db.commit() print 'before deactivating Alice' print db(db.p2.name=='Alice').update(is_active=False) print 'after deactivating Alice' db.commit() def test(): db = get_db_with_schema() db_ops(db) print db.p2._common_filter print 1, [r.name for r in db().select(db.p2.name)] print 2, [r.name for r in db(ignore_common_filters=False).select(db.p2.name)] print 3, [r.name for r in db(ignore_common_filters=True).select(db.p2.name)] print 4, [r.name for r in db(db.p2.is_active==True).select(db.p2.name)] if __name__ == __main__: test() $ sqlite3 -column -header storage.sqlite 'select * from p2;' id namedescription is_active -- -- --- -- 1 AliceF 2 Bob T $ python test_common_filter.py # against git main branch 1b0e08 before deactivating Alice 1 after deactivating Alice function lambda at 0x2aca500 1 ['Alice', 'Bob'] 2 ['Alice', 'Bob'] 3 ['Alice', 'Bob'] 4 ['Bob'] This is as if common_filter has no effect at all. I was expecting to see 1 ['Bob'] 2 ['Bob'] 3 ['Alice', 'Bob'] 4 ['Bob'] Did I miss something? Or is this a bug? Thanks! -Brian --
[web2py] sqlform date field format broken after validation fails
Hello I have the following problem: - i have a sqlform with a date field (which I customized with a jquery widget, that, among other things, changes the date format into dd/mm/yy) which works fine (displays the correct format after date selection) but if the form validation fails than the saved value of the date field gets reformatted back to '%Y-%m-%d' default format. this is the field value in the table: Field('data', 'date', widget=date_widget, requires=[IS_NOT_EMPTY(error_message=Completarea campului este obligatorie), IS_DATE('%d/%m/%Y', error_message = 'Data trebuie sa aiba formatul ZZ/LL/') ], label=Data Nasterii, comment=) db.table.data.represent = lambda value,row : value.strftime('%d/%m/%Y') and the date widget: def date_widget(f, v): wrapper = DIV() inp = SQLFORM.widgets.string.widget(f, v, _class=jqdate) jqscr = SCRIPT( jQuery(document).ready(function(){\ jQuery('#%s').datepicker({\ dateFormat:'dd/mm/yy',\ showOtherMonths:true,\ selectOtherMonths:true,\ changeYear:true,\ yearRange: '-80:+0',\ changeMonth:true\ });\ }); % inp['_id'], _type=text/javascript) wrapper.components.extend([inp, jqscr]) return wrapper also i have included the translation in my language file: '%Y-%m-%d' : '%d/%m/%Y', '%Y-%m-%d %H:%M:%S': '%d/%m/%Y %H:%M:%S', '%d.%m.%Y': '%d.%m.%Y', '%d.%m.%Y %H:%M:%S': '%d.%m.%Y %H:%M:%S', '%d/%m/%Y': '%d/%m/%Y', '%d/%m/%Y %H:%M:%S': '%d/%m/%Y %H:%M:%S', and changed the default format in web2py_ajax.html: var w2p_ajax_date_format = {{=T('%d/%m/%Y')}}; var w2p_ajax_datetime_format = {{=T('%d/%m/%Y %H:%M:%S')}}; i'm running out of ideas so i thought maybe you could help. thanks 'web2py newbie' :) --
[web2py] common_filter not working?
#!/usr/bin/env python # export PYTHONPATH=.../web2py from gluon import DAL, Field def def_tables(db): p2 = db.define_table('p2', Field('name', 'string'), Field('is_active', 'boolean', default=True), common_filter = lambda q: db.p2.is_active==True) def get_db(): return DAL('sqlite://storage.sqlite') def get_db_with_schema(): db = get_db() def_tables(db) return db def db_ops(db): db.p2.truncate() db.p2.insert(name='Alice') db.p2.insert(name='Bob') db.commit() print 'before deactivating Alice' print db(db.p2.name=='Alice').update(is_active=False) print 'after deactivating Alice' db.commit() def test(): db = get_db_with_schema() db_ops(db) print db.p2._common_filter print 1, [r.name for r in db().select(db.p2.name)] print 2, [r.name for r in db(ignore_common_filters=False).select(db.p2.name)] print 3, [r.name for r in db(ignore_common_filters=True).select(db.p2.name)] print 4, [r.name for r in db(db.p2.is_active==True).select(db.p2.name)] if __name__ == __main__: test() Ran against trunk 1b0e08. Inspecting DB, Alice has been successfully updated, is_active set to F. I expect to see ['Bob'] in print out 1, 2, and 4. But I'm seeing before deactivating Alice 1 after deactivating Alice function lambda at 0x315a500 1 ['Alice', 'Bob'] 2 ['Alice', 'Bob'] 3 ['Alice', 'Bob'] 4 ['Bob'] Did I miss anything, or shall I file a bug? Thanks, -Brian --
[web2py] tengo problemas con web2py. Actualice ubuntu a ubuntu 12.04 .
Tengo Problemas con web2py. Actualice ubuntu a ubuntu a 12.04 y ahora al ingresar a web2py marca error en el index de welcome. marcándome el siguiente error en la terminal. http://127.0.0.1:8000 a partir navegador ... Excepción AttributeError: AttributeError (objeto _DummyThread 'no tiene un atributo' _Thread__block ',) en'threading' modulo de'/usr/lib/python2.7/threading.pyc' ignorado desde ya gracias !!! --
[web2py] Securité Blog
Bonjour tous S'il vous plaît y'a t-il une methode pour bloquer des ip par pays , sur blogger merci d'avance --
Re: [web2py] Database table prefix
Well, ideal for me would be to define a prefix in the model file and this is automatically added to every defined table and all queries (no idea if it is possible). But this multi-tenancy looks interesting as well, so I will look into it... Thanks! Regards, Chris On Monday, November 26, 2012 4:17:57 PM UTC+1, Anthony wrote: Do you have a proposal for how an easier implementation should work? Also, rather than separate tables for different clients, have you considered either multi-tenancyhttp://web2py.com/books/default/chapter/29/06#Common-fields-and-multi-tenancyor just using separate databases (in the latter case, you could just define the DAL connection string dynamically to refer to the appropriate database)? Anthony On Monday, November 26, 2012 10:09:18 AM UTC-5, Chr_M wrote: I guess that nobody has ever had a need for this and that there is not really a solution for it? Regards, Chris On Friday, November 23, 2012 9:09:24 PM UTC+1, Chr_M wrote: That, but even the same app using different tables in the same db (but for different cliënts)... Regards, Chris On Friday, November 23, 2012 7:00:28 PM UTC+1, Richard wrote: Why exactly you change prefix? Installing differents apps dbs in the same db? Richard On Fri, Nov 23, 2012 at 10:57 AM, Chr_M chr@gmail.com wrote: Hi, I am new to web2py and am migrating an application to web2py. All the tables have a prefix that changes for the different deployments of the application. Is there a way in web2py to have a prefix for all the tables in the database that I can change easely for different deployments? At this time I use a PREFIX = 'prefix_' constant and define tables with db.define_table(PREFIX + 'table_name', etc... but this is becoming a bit complicated when defining requirements etc. Maybe there is an easier solution? Thanks in advance. Regards, Chris -- --
[web2py] Single session for an individual login - possible?
Hello everyone! I am evaluating web2py framework for suitability in order to accomplish one of my client's project - basically, an application reading the data from the database and displaying it on interactive charts, depending on the options chosen. Web2py seems to be a perfect choice as application is going to be used by fairly big but yet limited number of users, and the pre-configuration pre-configuration pre-configuration, DAL model and admin panel it provides perfectly suites my needs. There is one demand I have that I cannot easily figure out from the book. I want to only allow one authenticated session at a time for an individual login in my application. When (if) I detect multiple logins using same credentials but from different machines I want to deny access to the second user and inform about the situation the first one (or other action accordingly). Regarding my studies, I fairly see it possible to fulfil this demand using web2py itself, but maybe some external libraries could help? Anyone ever faced same issue? Thank you for advice! KBS --
[web2py] Re: How to open a ticket on the web2py itself?
Now - another question. How to REOPEN an issue? BTW: look at the issue: http://code.google.com/p/web2py/issues/detail?id=1173 Once it's marked as closed I don't have the permission to reopen the issue even if the bug was not fixed correctly. In the bugtracker I used to use - (FogBugz) the issue was automatically re-opened once somebody posted something about it. I don't think it's the case with Google Code. Thanks, Maciej W dniu czwartek, 15 listopada 2012 02:24:23 UTC+1 użytkownik Tim Richardson napisał: On Thursday, 15 November 2012 01:22:46 UTC+11, Massimo Di Pierro wrote: http://code.google.com/p/web2py/issues/list I agree this should be more prominent in the web site. +1 :) --
[web2py] Re: Single session for an individual login - possible?
Uhm, did you try to do session.connect(request,response,check_client=True) ? Il giorno lunedì 26 novembre 2012 17:26:52 UTC+1, KBS ha scritto: Hello everyone! I am evaluating web2py framework for suitability in order to accomplish one of my client's project - basically, an application reading the data from the database and displaying it on interactive charts, depending on the options chosen. Web2py seems to be a perfect choice as application is going to be used by fairly big but yet limited number of users, and the pre-configuration pre-configuration pre-configuration, DAL model and admin panel it provides perfectly suites my needs. There is one demand I have that I cannot easily figure out from the book. I want to only allow one authenticated session at a time for an individual login in my application. When (if) I detect multiple logins using same credentials but from different machines I want to deny access to the second user and inform about the situation the first one (or other action accordingly). Regarding my studies, I fairly see it possible to fulfil this demand using web2py itself, but maybe some external libraries could help? Anyone ever faced same issue? Thank you for advice! KBS --
[web2py] Re: Sharing a database between apps
Ok, thanks. I guess that makes sense. But then how do the models/*.py files fit it? Are these only used for migration? What if I want to have different auth tables but share all others? --
[web2py] V 2.2.1 linked_tables broken in smartgrid?
Smartgrid isn't picking up linked tables in V 2.2.1. Could I be missing something obvious? Any suggestions gratefully accepted. Here are three tables from my model. db.define_table( 'suppliers', Field('name', length=256, required=True, notnull=True), Field('address', length=64), Field('address_2', length=64), # details omitted ) db.define_table( 'supplier_contacts', Field('supplier_id', db.suppliers), Field('first_name', length=32, required=True, notnull=True), # details omitted ... ) db.define_table('product_suppliers', Field('product_id', db.products), Field('supplier_id', db.suppliers), Field('lead_time', 'integer', # details omitted ) The smartgrid from this controller code fails to contain a link to supplier_contacts. Worse, if I add a linked_tables argument the grid displays no links at all. def smartindex(): form = SQLFORM.smartgrid( db.suppliers, ##linked_tables = [ ##db.supplier_contacts ##], # links_in_grid=True, # fields=[db.suppliers.name], ) return dict(form=form) --
Re: [web2py] Database table prefix
You can't create more db? If you use postgres database, you could have look at schema, they serves that purpose, and I am not sure but I think I read that web2py now support postgres schemas. Richard On Fri, Nov 23, 2012 at 3:09 PM, Chr_M chr.m...@gmail.com wrote: That, but even the same app using different tables in the same db (but for different cliënts)... Regards, Chris On Friday, November 23, 2012 7:00:28 PM UTC+1, Richard wrote: Why exactly you change prefix? Installing differents apps dbs in the same db? Richard On Fri, Nov 23, 2012 at 10:57 AM, Chr_M chr@gmail.com wrote: Hi, I am new to web2py and am migrating an application to web2py. All the tables have a prefix that changes for the different deployments of the application. Is there a way in web2py to have a prefix for all the tables in the database that I can change easely for different deployments? At this time I use a PREFIX = 'prefix_' constant and define tables with db.define_table(PREFIX + 'table_name', etc... but this is becoming a bit complicated when defining requirements etc. Maybe there is an easier solution? Thanks in advance. Regards, Chris -- -- --
[web2py] Self-joins not working.
The documentation at http://web2py.com/books/default/chapter/29/06?search=reference#Self-Reference-and-aliases says that this should be possible. However my models code in db_wizard.py which I've partially edited just for this requirement does not generate the correct CRUD form ( a lookup list-box). What do I need to change to make this work correctly? Here is my models code... db.define_table('t_project', Field('f_name', type='string', label=T('Name')), Field('f_parent_project', type='reference t_project', label=T('Parent Project')), Field('f_description', type='string', label=T('Description')), Field('f_start_on', type='date', label=T('Start On')), Field('f_colour', type='string', label=T('Colour')), Field('f_company_code', type='text', label=T('Company Code')), Field('f_status', type='boolean', label=T('Status')), auth.signature, format='%(f_name)s', migrate=settings.migrate) --
[web2py] web2py forum solutions
Hi, group. What are some options for forums/message boards that can be readily integrated into a web2py page (i.e. forum solutions that can be wholly contained within your page's content window, maintain the integrity of your page's theme, and have access to the page's DB - preferably with minimal fuss)? Thank you. --
Re: [web2py] Database table prefix
On Monday, November 26, 2012 7:38:31 PM UTC+1, Richard wrote: You can't create more db? If you use postgres database, you could have look at schema, they serves that purpose, and I am not sure but I think I read that web2py now support postgres schemas. no schema support in web2py ATM, sorry --
[web2py] Re: web2py forum solutions
Well, there is a forum written in web2py. Take a look - http://pyforum.org/ I haven't used it for more than to test it out, perhaps someone else will have additional feedback. Regards, Ales On Monday, November 26, 2012 8:16:51 PM UTC+1, Lamps902 wrote: Hi, group. What are some options for forums/message boards that can be readily integrated into a web2py page (i.e. forum solutions that can be wholly contained within your page's content window, maintain the integrity of your page's theme, and have access to the page's DB - preferably with minimal fuss)? Thank you. --
[web2py] Re: V 2.2.1 linked_tables broken in smartgrid?
Sorry I don't have an answer for you but can confirm that linked_tables are working fine for me in 2.2.1. -Jim On Monday, November 26, 2012 12:06:49 PM UTC-6, Cliff Kachinske wrote: Smartgrid isn't picking up linked tables in V 2.2.1. Could I be missing something obvious? Any suggestions gratefully accepted. Here are three tables from my model. db.define_table( 'suppliers', Field('name', length=256, required=True, notnull=True), Field('address', length=64), Field('address_2', length=64), # details omitted ) db.define_table( 'supplier_contacts', Field('supplier_id', db.suppliers), Field('first_name', length=32, required=True, notnull=True), # details omitted ... ) db.define_table('product_suppliers', Field('product_id', db.products), Field('supplier_id', db.suppliers), Field('lead_time', 'integer', # details omitted ) The smartgrid from this controller code fails to contain a link to supplier_contacts. Worse, if I add a linked_tables argument the grid displays no links at all. def smartindex(): form = SQLFORM.smartgrid( db.suppliers, ##linked_tables = [ ##db.supplier_contacts ##], # links_in_grid=True, # fields=[db.suppliers.name], ) return dict(form=form) --
[web2py] Re: Sharing a database between apps
Turn turn off migrations for all tables in the db: db = DAL(..., migrate_enabled=False) Anthony On Friday, October 7, 2011 12:24:11 PM UTC-4, Harshad wrote: Nice. So all I have to do is define them in every application that is using them and set migrate=False. And, next time I'll try to RTFM more carefully. Thanks Cliff! On Oct 7, 12:19 pm, Cliff cjk...@gmail.com wrote: Yes. More information is available here: http://web2py.com/book/default/chapter/04#Cooperation On Oct 7, 11:11 am, Harshad hash0...@gmail.com wrote: I was wondering if its possible to share a database between apps. I have two apps. One is a background process that discovers devices on the network using bonjour and adds them to the database. The other app provides a web interface to view these discovered devices. How do I share the same database? Do I define the table twice? --
[web2py] Re: Querying on 1:M Relationships in SQLFORM.grid and SQLFORM.smartgrid
+1 this would be a great and needed feature... just stumbled into this problem, and working around it :) On Friday, August 31, 2012 5:48:17 PM UTC-4, Massimo Di Pierro wrote: Hello Mike, thanks for your patch? Would you please attach it to a google code issue so we do not forget. We cannot add new feaures until all 2.0.x issues have been resolved. On Friday, August 31, 2012 2:41:30 PM UTC-5, Mike Leone wrote: Hello, We're building a web2py application that leverages SQLFORM.smartgrid heavily. Out of the box, this does not support filtering on 1:M relationships, or reference fields on the model. We understand the concerns about this: It could potentially be a huge performance hit, especially if the related table has a large number of rows. On the other hand, this functionality is very valuable. Being able to filter on related tables is a very common need in applications. Often, users need to filter on lookup tables that have a relatively small number of rows, and the performance hit is negligible. This is a very common feature in Django, and in Rails admin interfaces like ActiveScaffold and RailsAdmin. Example: Given a model like this: db.define_table('book', Field('user_id', 'reference auth_user'), Field('title'), Field('genre')) And a controller like this: def index(): grid = SQLFORM.smartgrid(db.book) return dict(grid=grid) The query interface will look like this by default: http://i49.tinypic.com/2ugjt02.jpg Note how this includes title and genre, but not the auth_user reference. We patched web2py to allow to for 1:M reference fields in the query interface. The resulting interface and generated query look something like this: http://i46.tinypic.com/28taq74.png Here is our simple patch to allow searching on reference fields like this: https://gist.github.com/ff543a5c6d3bc14b9079 This is obviously NOT ready for production; it's a simple proof of concept. Note the potentially very expensive ALL query. Because of the performance risks, something like this only makes sense if developers can opt in, i.e. explicitly say so if they want to include a given reference field in the query interface. 1. Would the web2py maintiners be interested in a feature like this if it is opt-in? I'm willing to devote some time to submit a more robust patch if I could get some guidance. 2. I also have a simple implementation for querying on list:reference fields that I can share as well. Finally, I just want to thank the web2py team. I've really enjoyed using the framework and hope to help out as much as I can. Thanks, Mike Leone Principal, Engineering Panoptic Development, Inc. --
[web2py] Re: V 2.2.1 linked_tables broken in smartgrid?
That alone is worth knowing. Do you identify the related tables using the db.tablename syntax or 'reference tablename' syntax? Do you call the referencing id, for example, 'supplier_id', or just 'supplier'? I'm guessing there's some subtle point I'm missing in my model files. On Monday, November 26, 2012 3:42:18 PM UTC-5, Jim S wrote: Sorry I don't have an answer for you but can confirm that linked_tables are working fine for me in 2.2.1. -Jim On Monday, November 26, 2012 12:06:49 PM UTC-6, Cliff Kachinske wrote: Smartgrid isn't picking up linked tables in V 2.2.1. Could I be missing something obvious? Any suggestions gratefully accepted. Here are three tables from my model. db.define_table( 'suppliers', Field('name', length=256, required=True, notnull=True), Field('address', length=64), Field('address_2', length=64), # details omitted ) db.define_table( 'supplier_contacts', Field('supplier_id', db.suppliers), Field('first_name', length=32, required=True, notnull=True), # details omitted ... ) db.define_table('product_suppliers', Field('product_id', db.products), Field('supplier_id', db.suppliers), Field('lead_time', 'integer', # details omitted ) The smartgrid from this controller code fails to contain a link to supplier_contacts. Worse, if I add a linked_tables argument the grid displays no links at all. def smartindex(): form = SQLFORM.smartgrid( db.suppliers, ##linked_tables = [ ##db.supplier_contacts ##], # links_in_grid=True, # fields=[db.suppliers.name], ) return dict(form=form) --
[web2py] Re: V 2.2.1 linked_tables broken in smartgrid?
Cliff In my table definition I use db.table_name just as in your example. And in my controller I have a mixture of both, some where I specify the linked tables and some where I just let smartgrid figure it out. Here is a sample model: benefitProgram = db.define_table('benefitProgram', Field('benefitProgramId', 'id', readable=False), Field('name', length=50, required=True, unique=True), format='%(name)s') db.benefitProgram.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, db. benefitProgram.name)] db.benefitProgram._plural = 'Benefit Programs' benefitLevel = db.define_table('benefitLevel', Field('benefitLevelId', 'id', readable=False), Field('benefitProgramId', db.benefitProgram, required=True, label='Benefit Program'), Field('name', length=50, required=True), format='%(name)s') db.benefitLevel.benefitProgramId.requires = IS_IN_DB(db, db.benefitProgram. benefitProgramId, '%(name)s', zero='..') db.benefitLevel.name.requires = IS_NOT_EMPTY() db.benefitLevel._plural = 'Benefit Levels' This works fine generating the smartgrid with links. -Jim On Monday, November 26, 2012 2:52:57 PM UTC-6, Cliff Kachinske wrote: That alone is worth knowing. Do you identify the related tables using the db.tablename syntax or 'reference tablename' syntax? Do you call the referencing id, for example, 'supplier_id', or just 'supplier'? I'm guessing there's some subtle point I'm missing in my model files. On Monday, November 26, 2012 3:42:18 PM UTC-5, Jim S wrote: Sorry I don't have an answer for you but can confirm that linked_tables are working fine for me in 2.2.1. -Jim On Monday, November 26, 2012 12:06:49 PM UTC-6, Cliff Kachinske wrote: Smartgrid isn't picking up linked tables in V 2.2.1. Could I be missing something obvious? Any suggestions gratefully accepted. Here are three tables from my model. db.define_table( 'suppliers', Field('name', length=256, required=True, notnull=True), Field('address', length=64), Field('address_2', length=64), # details omitted ) db.define_table( 'supplier_contacts', Field('supplier_id', db.suppliers), Field('first_name', length=32, required=True, notnull=True), # details omitted ... ) db.define_table('product_suppliers', Field('product_id', db.products), Field('supplier_id', db.suppliers), Field('lead_time', 'integer', # details omitted ) The smartgrid from this controller code fails to contain a link to supplier_contacts. Worse, if I add a linked_tables argument the grid displays no links at all. def smartindex(): form = SQLFORM.smartgrid( db.suppliers, ##linked_tables = [ ##db.supplier_contacts ##], # links_in_grid=True, # fields=[db.suppliers.name], ) return dict(form=form) --
[web2py] Re: V 2.2.1 linked_tables broken in smartgrid?
Thanks for the help. On Monday, November 26, 2012 4:12:22 PM UTC-5, Jim S wrote: Cliff In my table definition I use db.table_name just as in your example. And in my controller I have a mixture of both, some where I specify the linked tables and some where I just let smartgrid figure it out. Here is a sample model: benefitProgram = db.define_table('benefitProgram', Field('benefitProgramId', 'id', readable=False), Field('name', length=50, required=True, unique=True), format='%(name)s') db.benefitProgram.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, db. benefitProgram.name)] db.benefitProgram._plural = 'Benefit Programs' benefitLevel = db.define_table('benefitLevel', Field('benefitLevelId', 'id', readable=False), Field('benefitProgramId', db.benefitProgram, required=True, label='Benefit Program'), Field('name', length=50, required=True), format='%(name)s') db.benefitLevel.benefitProgramId.requires = IS_IN_DB(db, db.benefitProgram .benefitProgramId, '%(name)s', zero='..') db.benefitLevel.name.requires = IS_NOT_EMPTY() db.benefitLevel._plural = 'Benefit Levels' This works fine generating the smartgrid with links. -Jim On Monday, November 26, 2012 2:52:57 PM UTC-6, Cliff Kachinske wrote: That alone is worth knowing. Do you identify the related tables using the db.tablename syntax or 'reference tablename' syntax? Do you call the referencing id, for example, 'supplier_id', or just 'supplier'? I'm guessing there's some subtle point I'm missing in my model files. On Monday, November 26, 2012 3:42:18 PM UTC-5, Jim S wrote: Sorry I don't have an answer for you but can confirm that linked_tables are working fine for me in 2.2.1. -Jim On Monday, November 26, 2012 12:06:49 PM UTC-6, Cliff Kachinske wrote: Smartgrid isn't picking up linked tables in V 2.2.1. Could I be missing something obvious? Any suggestions gratefully accepted. Here are three tables from my model. db.define_table( 'suppliers', Field('name', length=256, required=True, notnull=True), Field('address', length=64), Field('address_2', length=64), # details omitted ) db.define_table( 'supplier_contacts', Field('supplier_id', db.suppliers), Field('first_name', length=32, required=True, notnull=True), # details omitted ... ) db.define_table('product_suppliers', Field('product_id', db.products), Field('supplier_id', db.suppliers), Field('lead_time', 'integer', # details omitted ) The smartgrid from this controller code fails to contain a link to supplier_contacts. Worse, if I add a linked_tables argument the grid displays no links at all. def smartindex(): form = SQLFORM.smartgrid( db.suppliers, ##linked_tables = [ ##db.supplier_contacts ##], # links_in_grid=True, # fields=[db.suppliers.name], ) return dict(form=form) --
[web2py] Re: tengo problemas con web2py. Actualice ubuntu a ubuntu 12.04 .
Looks like you need to patch your Python installation as rh suggests. BTW, there is a web2py users group for spanish here: http://groups.google.com/group/web2py-usuarios On Monday, November 26, 2012 11:10:36 AM UTC-3, Angel Segovia wrote: Tengo Problemas con web2py. Actualice ubuntu a ubuntu a 12.04 y ahora al ingresar a web2py marca error en el index de welcome. marcándome el siguiente error en la terminal. http://127.0.0.1:8000 a partir navegador ... Excepción AttributeError: AttributeError (objeto _DummyThread 'no tiene un atributo' _Thread__block ',) en'threading' modulo de'/usr/lib/python2.7/threading.pyc' ignorado desde ya gracias !!! --
Re: [web2py] Re: we should support this in DAL
Yeah, something like that I would think. Is there a generic set of queries that some/most/all of certain types of NoSQL DBs share? Mongo is nice to support but also Postgres, Redis, etc. Are there some queries where DAL-style syntax makes sense? For example selecting for an item or set of items (without a join, I suppose)? And then being able to turn any result sets into Rows object would be good. On Monday, November 26, 2012 6:23:10 AM UTC-8, rochacbruno wrote: I think DAL has nothing to do with Mongo. It is much easier to use only PyMongo API. What we really need is a Rows factory it shoul take arbitrary data format (can have a scheme) and will give us back a Rows object. Also it should have some event binders to update, delete, insert... So programmers will do this: mydata = pymongo.whatever() # pymongo dict like objects rows = gluon.RowsFactory(mydata, scheme=myscheme, updater=lambda, inserter=lambda, deleter=lambda) now we should have a Rows object and it could be used for grid, forms etc... The problem is that it can take long time to convert things in to Rows. So the best should be a dict + events based Form, grid and other controls designed specifically for these cases. Bruno Rocha http://rochacbruno.com.br mobile Em 26/11/2012 04:06, Mark Kirkwood mark.k...@gmail.com javascript: escreveu: I am wondering if there are some deeper issues getting NoSQL support in Web2py - for instance the model part seems pretty tied into relational ideas (e.g db.define_table and ..references db.dog etc). This design works really well and insulates developers from much of the fiddlyness of dealing directly with relation db's quirks, but the ideas themselves are clearly relational. The other big DAL issue would be joins..but I guess integration with GAE has covered that to some extent (tho it looks like GAE can kinda fake a join with referenced properties...might be able to do something like that with Mongo, but not for all other NoSQLs). On Wednesday, November 21, 2012 11:58:35 PM UTC+13, Niphlod wrote: that is exactly the explanation of the term experimental. The problem as always is that if noone starts to test it, it will be in this way forever. On Tuesday, November 20, 2012 11:25:59 PM UTC+1, Simon Ashley wrote: The bottom line seems to be that we/ others need to start to use nosql engines to sort the issues. My guess is that, currently, critical mass is not present to rely on it for production sites. -- --
[web2py] web3py?
I noticed a thread over in web2py-developers web3py - important!https://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/RCeiRd3Rzs0 which was exciting to read. I've flirted with web2py and there's a lot that I like about it. For some reason I find web2py exciting whereas django doesn't provide that. I've used Yii on the php side which is great framework as far as php goes and asp.net mvc which is great as well. I'd love to work with python but the main thing making me hesitate with web2py is critical mass. It seems like it wouldn't be hard for web2py to really dominate the python web framework space if some of the core criticisms were addressed. I'm not fully up to speed on what they are but I usually hear about unit testing and global variables. It feels like there is a roadblock preventing the project from skyrocketing. Python needs a rails. I understand that the design decisions are by choice with pros and cons. My questions are: 1. Will web3py likely address these often repeated core criticisms? (I saw point 5 from the thread linked to above: 5) No more global environment. Apps will do from web3py import * (see below)) 2. The developer thread is over in the developers section. Will you have a more open forum for users (as opposed to developers) to have input on web3py? --
[web2py] Re: Unable to send email in web2py
Do you use McAfee on the server? I also couldn't send emails by web2py a few months ago. Later, I found out that McAfee blocked the connection. McAfee only allow a list of applications to send emails, but web2py isn't on the list. So, I renamed web2py.exe to apache.exe, then emails can go through. Mark On Wednesday, November 21, 2012 2:32:26 PM UTC-5, Daniele wrote: I'm trying to send emails upon user registration. This is what I have in my models file: mail = auth.settings.mailer mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = 'em...@gmail.com javascript:' #There's a proper email here mail.settings.login = 'username:password' #There's a proper username/password combination here auth.settings.registration_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + request.env.http_host + URL(r=request,f='user',args=['verify_email']) + '/%(key)s to verify your email' mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login But every time I register a user with a valid email address, I'm getting no email. So I'm trying to do it manually with: mail.send('em...@gmail.com javascript:', 'Message subject', 'Plain text body of the message') But I'm getting an error message in the terminal that says: WARNING:web2py:Mail.send failure:[Errno 111] Connection refused How can I fix this??? --
[web2py] How to run expire_sessions.py in 2.2.1?
After upgraded to 2.2.1 from 1.99.7, the crontab expire_sessions.py didn't work with web2py -Y -L options.py There are too tasks in my crontab: 0 4 * * * root *admin/backup 0 5 * * * root **applications/admin/cron/expire_sessions.py The first backup cron is still running well. I try to run expire_sessions.py in command line: web2py -S admin -R applications/admin/cron/expire_sessions.py web2py -S myapp -R applications/admin/cron/expire_sessions.py With -S myapp option, the expire_sessions.py did work for myapp, but -S admin option didn't. Thanks, Mark --
[web2py] set field values in sqlform.grid new page
When using sqlform.grid, and after clicking add within its list, I need a way to set the default value for a field in the screen that comes next. I can't do this on the database layer, the value will not be that consistent. I need a way to do this in the controller or view (preferably the view). I think I understand how this works with a normal form (form.vars.field='') but I can not figure out how to do it (or if it's possible) from the form sqlform.grid generates. I already have sqlform.grid add sending me to a custom view but I can't get any further. Apologies if I'm overlooking something obvious. --
[web2py] Disabling Bootstrap?
Is there a clean way to disable the bootstrap functionality in web2py, either in layout.html or in one of the various bootstrap*.css files? Removing the bootstrap-related CSS files is not reasonable, as it also removes some necessary styles. Even being able to change the width at which bootstrap is initiated would be helpful. Thank you, Eric --
[web2py] Re: Securité Blog
Dans un controleur tu peux accéder à l'adresse IP avec request.env.remote_host Tu peux alors la comparer avec un début particulier: if request.env.remote_host.startswith(132.10.):#mettre le début de l'IP à bloquer ici raise HTTP(403,Not authorized) Sinon tu peux programmer un module qui communique avec un webservice qui te géolocalise cette IP: http://www.scriptol.fr/comment/savoir-le-pays-pour-une-ip.php Bon courage. PS : Essaie plutôt de poser des questions ici en anglais, plus de gens pourront te répondre. Le lundi 26 novembre 2012 14:55:11 UTC+1, Ala Hernandez a écrit : Bonjour tous S'il vous plaît y'a t-il une methode pour bloquer des ip par pays , sur blogger merci d'avance --
[web2py] error in jsonrpc doc
web2py doc, Ch. 10 section on JSONRPC service has unfinished line: from gluon.contrib.simplejsonrpc import should read from gluon.contrib.simplejsonrpc import ServerProxy --