[web2py] Re: Web2Py and Ajax
Thanks for your quick response. Op vrijdag 21 december 2012 07:14:32 UTC+1 schreef Massimo Di Pierro het volgende: > > if not request.ajax: > > On Thursday, December 20, 2012 9:35:02 AM UTC-6, Martijn Hermans wrote: >> >> I've just started using web2py and have a question about ajax calls. >> >> In my project a menu is defined (and build) in models/meny.py). >> The menu is added to the response like this : response.menu = _menu() >> >> In this way I can access the menu in my layout and that is exacly what I >> want, except... >> >> when I am doing a ajax call. >> >> Is there a way to skip building my menu when I'm using a ajax call? >> >> >> >> --
Re: [web2py] Web2Py and Ajax
Thanks for your quick response. Op vrijdag 21 december 2012 06:14:25 UTC+1 schreef rochacbruno het volgende: > > if not request.ajax: > response.menu = _menu() > > On Thu, Dec 20, 2012 at 1:52 PM, Martijn Hermans > > > wrote: > >> When I handle a request in Web2Py it builds a menu in models/menu.py. >> This behaviour is exactly what I want for a normal request, but I want to >> skip this, when I make an ajax-call. >> >> Is this possible? >> >> thx, >> >> Martijn >> >> -- >> >> >> >> > > --
[web2py] radio widget styling.
I defined the following field: Field('moduleID',type='integer',requires=IS_EMPTY_OR(IS_IN_SET([ABOUTGROUPID,CALENDARGROUPID],labels=['About','Kalender'])),widget=SQLFORM.widgets.radio.widget,label='Module * '), In the form the radio widget is rendered as a table with the label beneath the input, I' d like to have the label to the right of the input. How do I get this done? I tried: widget=SQLFORM.widgets.radio.widget(style='ul') but tat results in an error: 1 attribute provided where 3 are needed. Kind regards, Annet --
Re: [web2py] Re: Question about SQLFORM.grid - process a column before show it
Wow!! Thanks Niphlod, this tip worked like a charm!! El jueves, 20 de diciembre de 2012 20:53:14 UTC-3, Niphlod escribió: > > my bad, sorry Christian. > > myset = { 0:'Quiet',1:'Running',2:'Fail'} > > Field('action', 'integer', > requires=IS_IN_SET(myset), > represent=lambda value, row: myset.get(value, None) > # or myset[value] if you are totally sure that myset contains > all the possible values > ) > > > Tested ! > > On Friday, December 21, 2012 12:13:11 AM UTC+1, villas wrote: >> >> I guess you need to use: actions.represent as well. >> >> >> On Thursday, December 20, 2012 9:46:58 PM UTC, Niphlod wrote: >>> >>> Disclaimer: not tested >>> why don't you just change the action Field to >>> >>> Field('action', requires=IS_IN_SET({ 0:'Quiet',1:'Running',2:'Fail'})) >>> >>> On Thursday, December 20, 2012 10:23:07 PM UTC+1, Jim S wrote: Have you though about adding a table to define the relation between 'index' and the text: db_actions.define_table('actions', Field(name, length=20, label='Action')) Then modify db_events so field index looks like: Field('index', db.actions, label='Action), Table actions would then have three records, Quiet Running Fail This should then automatically display the right value - the only problem is that it wouldn't guarantee that the index would be 0, 1, and 2. It would be whatever the primary key on the actions table worked out to be. The other way to handle it would be to write a custom validator that changed the numeric value as you mentioned. I haven't done that before, but heard it isn't that difficult. -Jim On Thu, Dec 20, 2012 at 2:45 PM, Christian Espinoza >>> > wrote: > My Model for this App > db_events.define_table('events', > Field('devid', length=15, label='CODE'), > Field('type', length=15, label='Type'), > Field('index','integer', label='Action'), > Field('datetime','datetime', label='Date'), > Field('latitude','double', label='Lat'), > Field('longitude','double', label='Lon'), > Field('velocity','double', label='Vel'), > Field('heading', 'integer', label='Dir'), > Field('pfm','integer', label='PFM'), > Field('age','integer', label='Age'), > Field('odometer','double', label='Od') > ) > -- > > > > --
Re: [web2py] Re: json service
Il 20/12/12 20:11, Massimo Di Pierro ha scritto: yes. You are not supposed to return an iterable (in your case a list). web2py thinks you want to do streaming and will start looping over the iterable. This should change in web3py not we cannot change it in web2py. Massimo Thanks Massimo, so the solution is to retur a dictionary containing my list, right? Cheeres Manuele --
[web2py] Re: radio widget styling.
widget=lambda k,v: SQLFORM.widgets.radio.widget(k,v,_style='ul') On Friday, 21 December 2012 03:19:16 UTC-6, Annet wrote: > > I defined the following field: > > Field('moduleID',type='integer',requires=IS_EMPTY_OR(IS_IN_SET([ABOUTGROUPID,CALENDARGROUPID],labels=['About','Kalender'])),widget=SQLFORM.widgets.radio.widget,label='Module > > * '), > > > In the form the radio widget is rendered as a table with the label beneath > the input, I' d like to have the label to the right of the input. > How do I get this done? > > I tried: > > widget=SQLFORM.widgets.radio.widget(style='ul') but tat results in an > error: 1 attribute provided where 3 are needed. > > > Kind regards, > > Annet > > --
Re: [web2py] Re: json service
yes. never return a list unless it is a list of strings you want to stream or a generator of strings. On Friday, 21 December 2012 07:27:41 UTC-6, Manuele wrote: > > Il 20/12/12 20:11, Massimo Di Pierro ha scritto: > > yes. > > > > You are not supposed to return an iterable (in your case a list). > > web2py thinks you want to do streaming and will start looping over the > > iterable. This should change in web3py not we cannot change it in > web2py. > > > > Massimo > Thanks Massimo, > so the solution is to retur a dictionary containing my list, right? > > Cheeres > > Manuele > --
[web2py] Direct Client Opening for Position : Java Developer Location : Topeka KS
Hi, *Do quick response at ank...@eruditionweb.com*, Please review the below Job Description and let me know if you are comfortable, Position : Java Developer Location : Topeka KS Duration : Long Term Project Description : We are currently engaged in a very large project to implement a Benefit Repository System to streamline the setup of new products, new groups and eligibility. We are also moving existing mainframe applications to browser based technology and replacing our existing IMS databases with zOS DB2 databases. Java Designer/Developer - Has expertise and is a skilled architectural designer and developer with the technical skill set to include: Object Oriented Design and Development methodologies, JAVA Programming Language,JAVA Server Faces (JSF) and Java Server Pages (JSP), AJAX Frameworks, JAVA Persistence Architecture (JPA), EJB 3.0, JDBC, JavaScript, HTML, CSS, XML, J-Unit Testing, Automated Build / Continuous Integration Environment, RSA/RAD 7.5, and Relational Database Systems and SQL, z/OS DB2 preferred. Has experience and ability to architect and recommend the design of a large system, familiarity with SCRUM methodology. Accounting background or billing system experience would be a plus. Can write specs, gets along well with people and has good communication skills. Bachelor?s Degree with emphasis in Computer Science preferred. Masters Degree would be a plus. Thanks Ankit R Erudition Web Technologies 785-783-5571 --
[web2py] Re: Beware auth.enable_record_versioning
Yes, but I don't think it will be today. On Friday, December 21, 2012 1:20:03 AM UTC-5, Massimo Di Pierro wrote: > > This helped me a lot understand the problem. I believe I have a fix in > trunk. Can you please check if the problem is indeed solved? > > On Thursday, December 20, 2012 1:21:21 PM UTC-6, Cliff Kachinske wrote: >> >> To enable archiving, I added enable_record_versioning(db) = True to my >> models files. >> >> I encountered the problems described in the two bug reports I submitted >> today on Google code. >> >> At one point I thought it would help with isolating the problem if I >> turned off versioning, so I commented out the line enabling it. >> >> When I uncommented the line, I found tables with names like >> "products_archive_archive." These are archive tables for the archive >> tables. >> >> I suppose if I repeated the sequence I would have tables with names like >> "products_archive_archive_archive." >> >> On Thursday, December 20, 2012 10:05:25 AM UTC-5, Massimo Di Pierro wrote: >>> >>> I do not understand. Can you explain? >>> >>> On Thursday, 20 December 2012 08:11:42 UTC-6, Cliff Kachinske wrote: I just discovered that auth.enable_record_versioning will create archive tables for the archive tables if turned off and turned back on. Not acceptable. >>> --
[web2py] 2.2.1 left joins broken?
Salient details from two tables: db.define_table( 'suppliers', Field('name', length=256, required=True, notnull=True), db.define_table( 'supplier_contacts', Field('supplier_id', db.suppliers), Field('first_name', length=32, required=True, notnull=True), The code below worked in 1.99.7. If the supplier had two contacts, it would return two rows as expected, both with the same supplier data but each with individual contact data. In 2.2.1 it returns no rows. def get_approved_suppliers(product_id): return db( (db.product_suppliers.product_id==product_id) & (db.product_suppliers.supplier_id==db.suppliers.id) ).select( db.suppliers.id, db.suppliers.name, # more supplier details omitted for brevity, db.supplier_contacts.id, db.supplier_contacts.first_name, # contact details omitted for brevity. left = db.supplier_contacts.on( db.supplier_contacts.supplier_id==db.suppliers.id ) ) This is the query as shown by db._lastsql. (Broken into chunks for readability) SELECT suppliers.id, suppliers.name, suppliers.address, suppliers.address_2 , suppliers.city, suppliers.state, suppliers.zip, suppliers.land_line,suppliers .fax, suppliers.email, suppliers.website, supplier_contacts.id,supplier_contacts .first_name, supplier_contacts.middle_name, supplier_contacts.last_name,supplier_contacts .generation, supplier_contacts.email, supplier_contacts.mobile,supplier_contacts .land_line, supplier_contacts.fax FROM product_suppliers, suppliers LEFT JOIN supplier_contacts ON (supplier_contacts.supplier_id = suppliers.id ) WHERE (product_suppliers.product_id = 340) AND (product_suppliers.supplier_id = suppliers.id)) AND (product_suppliers.is_active = 'T')) AND (suppliers.is_active = 'T')) AND (supplier_contacts.is_active = 'T')); --
[web2py] Re: 2.2.1 left joins broken?
It looks to be the generated SQL is correct. It is possible you enabled record versioning and that added the common_filter is_active==True. Yet perhaps you have records with is_active=None and therefore they showed up before and not now. On Friday, 21 December 2012 10:50:13 UTC-6, Cliff Kachinske wrote: > > Salient details from two tables: > > db.define_table( > 'suppliers', > Field('name', length=256, required=True, notnull=True), > > > > db.define_table( > 'supplier_contacts', > Field('supplier_id', db.suppliers), > Field('first_name', length=32, required=True, notnull=True), > > > > The code below worked in 1.99.7. If the supplier had two contacts, it > would return two rows as expected, both with the same supplier data but > each with individual contact data. > > In 2.2.1 it returns no rows. > > def get_approved_suppliers(product_id): > > return db( > (db.product_suppliers.product_id==product_id) & > (db.product_suppliers.supplier_id==db.suppliers.id) > ).select( > db.suppliers.id, > db.suppliers.name, > # more supplier details omitted for brevity, > db.supplier_contacts.id, > db.supplier_contacts.first_name, > # contact details omitted for brevity. > left = db.supplier_contacts.on( > db.supplier_contacts.supplier_id==db.suppliers.id > ) > ) > > > This is the query as shown by db._lastsql. (Broken into chunks for > readability) > > SELECT suppliers.id, suppliers.name, suppliers.address, suppliers. > address_2, suppliers.city, suppliers.state, suppliers.zip, suppliers. > land_line, suppliers.fax, suppliers.email, suppliers.website,supplier_contacts > .id, supplier_contacts.first_name, > supplier_contacts.middle_name,supplier_contacts > .last_name, supplier_contacts.generation, > supplier_contacts.email,supplier_contacts > .mobile, supplier_contacts.land_line, supplier_contacts.fax > > FROM product_suppliers, suppliers > > LEFT JOIN supplier_contacts ON (supplier_contacts.supplier_id = suppliers. > id) > > WHERE (product_suppliers.product_id = 340) AND > (product_suppliers.supplier_id > = suppliers.id)) AND (product_suppliers.is_active = 'T')) AND > (suppliers.is_active > = 'T')) AND (supplier_contacts.is_active = 'T')); > > > > > --
[web2py] Re: 2.2.1 left joins broken?
SQL is incorrect. is: "AND supplier_contacts.is_active = 'T'" should be "AND (supplier_contacts.is_active = 'T' OR supplier_contacts.is_active IS NULL)" On Friday, December 21, 2012 1:05:16 PM UTC-5, Massimo Di Pierro wrote: > > It looks to be the generated SQL is correct. It is possible you enabled > record versioning and that added the common_filter is_active==True. Yet > perhaps you have records with is_active=None and therefore they showed up > before and not now. > > On Friday, 21 December 2012 10:50:13 UTC-6, Cliff Kachinske wrote: >> >> Salient details from two tables: >> >> db.define_table( >> 'suppliers', >> Field('name', length=256, required=True, notnull=True), >> >> >> >> db.define_table( >> 'supplier_contacts', >> Field('supplier_id', db.suppliers), >> Field('first_name', length=32, required=True, notnull=True), >> >> >> >> The code below worked in 1.99.7. If the supplier had two contacts, it >> would return two rows as expected, both with the same supplier data but >> each with individual contact data. >> >> In 2.2.1 it returns no rows. >> >> def get_approved_suppliers(product_id): >> >> return db( >> (db.product_suppliers.product_id==product_id) & >> (db.product_suppliers.supplier_id==db.suppliers.id) >> ).select( >> db.suppliers.id, >> db.suppliers.name, >> # more supplier details omitted for brevity, >> db.supplier_contacts.id, >> db.supplier_contacts.first_name, >> # contact details omitted for brevity. >> left = db.supplier_contacts.on( >> db.supplier_contacts.supplier_id==db.suppliers.id >> ) >> ) >> >> >> This is the query as shown by db._lastsql. (Broken into chunks for >> readability) >> >> SELECT suppliers.id, suppliers.name, suppliers.address, suppliers. >> address_2, suppliers.city, suppliers.state, suppliers.zip, suppliers. >> land_line, suppliers.fax, suppliers.email, >> suppliers.website,supplier_contacts >> .id, supplier_contacts.first_name, >> supplier_contacts.middle_name,supplier_contacts >> .last_name, supplier_contacts.generation, >> supplier_contacts.email,supplier_contacts >> .mobile, supplier_contacts.land_line, supplier_contacts.fax >> >> FROM product_suppliers, suppliers >> >> LEFT JOIN supplier_contacts ON (supplier_contacts.supplier_id = suppliers >> .id) >> >> WHERE (product_suppliers.product_id = 340) AND >> (product_suppliers.supplier_id >> = suppliers.id)) AND (product_suppliers.is_active = 'T')) AND >> (suppliers.is_active >> = 'T')) AND (supplier_contacts.is_active = 'T')); >> >> >> >> >> --
Re: [web2py][outsource] Need a plugin that integrate jsTree or other tree plugin with closure table app
I am interested in tree widget too, have you evaluated 1) http://dev.s-cubism.com/plugin_jstree 2) http://dev.s-cubism.com/plugin_mptt which is based on Nested Set W On Thursday, September 20, 2012 3:21:14 PM UTC-4, Richard wrote: > > 1) > Users are defining information into simple form where is will be easier to > allow them to create hierarchy... About nestedSortable as long as it is > well supported by the owner of the project no problem about the js plugin > used. > > 2) > Bill Karwin lecture convinces me that it was the cleaner way of doing > thing. Also, my data are already structured that way. The relation between > node are not going to move that much (not move at all once establish), it > may happen that when node will be created there will be mistake that will > need to be corrected, but then no change will happen (that may have no > consequence on the programmation since the moving of subnode are be > required anyway). > > Thanks > > Richard > > On Thu, Sep 20, 2012 at 2:00 PM, Vasile Ermicioi > > > wrote: > >> may I ask a few questions >> >> 1) (a suggestion) >> why do you need multiselect if jstree already support drag drop? >> http://www.jstree.com/documentation/dnd# >> and I didn't see a better way to manipulate hierarchical data than what >> it offers >> an alternative is nestedSortable >> http://mjsarfatti.com/sandbox/nestedSortable/ but when you want to move >> a node with a lot of children it has poor performance >> >> >> 2) (interested because I did research some time ago on that field) >> why did you chose closure data model? >> >> -- >> >> >> >> > > --
[web2py] Problem with fields option of SQLFORM.grid
I have a problem using SQLFORM.grid and its fields option. fields= enables me to specify which fields to retrieve from the db, and those fields are then displayed to the user. The problem is, I would like to read from the database also some additional fields, which are NOT displayed to the user, but that can be used in generating links. For instance, I would like this code to work. Notice how I am not including db.submission.contest_id in the fields, but I would like to use it in the links (hence, this code is currently broken). Is there a way to do this? Shall I implement in web2py a new optional parameter for SQLFORM.grid called extra_fields? Many thanks! --Luca grid = SQLFORM.grid(q, fields=[db.submission.id, db.submission.date], csv=False, details=False, create=False, editable=False, user_signature=False, args=request.args[1:], links=[ dict(header=T('Contest'), body = lambda r: A(T('Contest'), _href=URL('contests', 'view_contest', args=[r.contest_id]))), dict(header=T('Submission'), body = lambda r: A(T('submission'), _href=URL('submission', 'view_own_submission', args=[r.id]))), dict(header=T('Feedback'), body = lambda r: A(T('feedback'), _href=URL('view_feedback', args=[r.id]))), ], ) --
Re: [web2py] Re: DB insert confusion
Yeah, yeah, yeah.. My on-the-fly testing code wasn't correct. ;) Checking with isinstance() is good but fails if params is just a string due to the data.get('params', '') a few lines up. Changing that to data.get('params', []) will resolve this or just drop elif isinstance(params, list): and change it to an else: catch || ifisinstance(params,dict): s =methods[method](**params) else: s =methods[method](*params) This way the called method will take defaults or error out if variables are not defined. Either way seems to work fine on my end. Niphlod wrote: > ok, let's try to not make any further confusion. Let's agree on what > web2py needs to provide and how to call it. > First things first: gluon.contrib.simplejsonrpc supports only 1.1, so > *only* positional arguments sent as lists. > jsonrpclib instead supports 2.0 spec, so *both* positional arguments > sent as lists and keyword arguments sent as dicts. > > Second thing: it's hard to follow some example if the example is never > going to work :P > > || > data =db(db.t_test.ALL).select() > returndict(data=data) > > will go on exception no matter what. > || > data =db().select(db.t_test.ALL) > returndict(data=data) > > works as intended. > > Third: decorated functions usually need to have arguments. > can we set on a > || > @service.jsonrpc > deftestlist(arg1,arg2): > data =db().select(db.t_test.ALL) > returndict(data=data,arg=arg1,arg2=arg2) > ? Right! > > Now, I think with a simple patch we can escape the "pass parameters as > a mapping or as a list" problem in gluon/tools.py > || > ifisinstance(params,dict): > s =methods[method](**params) > elifisinstance(params,list): > s =methods[method](*params) > > That should restore functionality for who calls functions only with > "positional" style, while retaining the "keywords" style feature. This > means that using contrib.simplejsonrpc you'll be able to call > > || > s.testlist(1,2) > > but not > || > > s.testlist(arg1=1,arg2=2) > > > NB: This is just because simplejsonrpc adheres only to the 1.1 spec > > With jsonrpclib, however, both will work ok (yeah!) > > If this is fine, we can further fine-tune responses (e.g. 'version': > '2.0' instead of 'version': '1.1') or having 2 separate @service > decorators as Jonathan suggested. > > Do we have a deal ? > > -- > > > -- - grutz; --
[web2py] Re: Problem with fields option of SQLFORM.grid
Ok, I figured it out, I can include db.submission.contest_id among the fields, and before calling SQLGRID.form, do db.submission.contest_id.readable = False Luca On Friday, December 21, 2012 12:42:37 PM UTC-8, Luca wrote: > > I have a problem using SQLFORM.grid and its fields option. > fields= enables me to specify which fields to retrieve from the db, and > those fields are then displayed to the user. > The problem is, I would like to read from the database also some > additional fields, which are NOT displayed to the user, but that can be > used in generating links. For instance, I would like this code to work. > Notice how I am not including db.submission.contest_id in the fields, but > I would like to use it in the links (hence, this code is currently broken). > > Is there a way to do this? Shall I implement in web2py a new optional > parameter for SQLFORM.grid called extra_fields? > Many thanks! --Luca > > grid = SQLFORM.grid(q, > fields=[db.submission.id, db.submission.date], > csv=False, details=False, create=False, editable=False, > user_signature=False, > args=request.args[1:], > links=[ > dict(header=T('Contest'), body = lambda r: > A(T('Contest'), _href=URL('contests', 'view_contest', > args=[r.contest_id]))), > dict(header=T('Submission'), body = lambda r: > A(T('submission'), _href=URL('submission', > 'view_own_submission', args=[r.id]))), > dict(header=T('Feedback'), body = lambda r: > A(T('feedback'), _href=URL('view_feedback', args=[r.id > ]))), > ], > ) > > --
[web2py] Re: Query results from 2 children tables from same parent ordered by date
I have pb to show the coalesce date in view. I tried; exams_mutex['COALESCE(dataset1.date,dataset1.date)'] but it is not working? Le jeudi 20 décembre 2012 23:40:15 UTC+1, Mamisoa Andriantafika a écrit : > > I finally found the solution using COALESCE to merge and order date > columns: > > exams_mutex = db().select(db.dataset1.date.coalesce(db.dataset1.date), db. > dataset1.ALL, db.dataset2.ALL, left=[db.dataset1.on(db.mutex.i==0),db. > dataset2.on(db.mutex.i==1)], orderby=db.dataset1.date.coalesce(db.dataset2 > .date)) > > Mamisoa > > Le jeudi 20 décembre 2012 16:08:34 UTC+1, Massimo Di Pierro a écrit : >> >> Sorry I do not have a good solution at the moment. Can you open a ticket >> about this so we'll will not forget. For now you may want to consider >> creating a database view and selecting from the view. You would need to >> create a model (readonly) to access the view. >> >> On Wednesday, 19 December 2012 16:19:33 UTC-6, Mamisoa Andriantafika >> wrote: >>> >>> Best results to UNION I could have was using the mutex table trick: >>> >>> http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/ >>> with this syntax: >>> >>> exams_mutex = db().select(db.dataset1.ALL, db.dataset2.ALL, >>> left=[db.dataset1.on(db.mutex.i==0),db.dataset2.on(db.mutex.i==1)]) >>> >>> Two problems left: >>> >>> 1- how to merge the 2 date columns >>> 2- how to order then by date >>> >>> SQL answer is there: >>> >>> http://stackoverflow.com/questions/8245630/mysql-combine-two-date-fields-and-then-order-by >>> >>> SELECT >>> [some info], >>> GREATEST( ticket_date, ticket_history_date ) as latest_date >>> FROM >>> [tables and join] >>> ORDER BY >>> latest_date >>> >>> >>> Is is possible using to process it using DAL? >>> >>> Le dimanche 16 décembre 2012 17:40:22 UTC+1, Mamisoa Andriantafika a >>> écrit : Sorry I still get: "Cannot | incompatible Rows objects". I'll change the field name "date" you are very right. Le dimanche 16 décembre 2012 15:49:57 UTC+1, Massimo Di Pierro a écrit : > > My bad. Thry this: > > fields1 = [db.dataset1.date, db.dataset1.param1, > db.dateset1.patient_id] > fields2 = [db.dataset2.date, db.dataset2.test1, db.dateset2.patient_id] > rows = ( db(db.dataset1).select(*fields1) | > db(db.dataset2).select(*fields2) ).sort(lambda row: row.date) > > Mind that having a column called "date" will result in major headaches > in the future. > > On Sunday, 16 December 2012 03:15:46 UTC-6, Mamisoa Andriantafika > wrote: >> >> Hi again, >> >> "|" seems not to work because the column numbers is different between >> the 2 tables? >> >> >> Le samedi 15 décembre 2012 20:23:44 UTC+1, Massimo Di Pierro a écrit : >>> >>> If you have lots of records you may be able to do it with a database >>> view but that may be db specific. >>> >>> If you don't have too many records you can do: >>> >>> rows = ( db(db.dataset1).select() | db(db.dataset2).select() >>> ).sort(lambda row: row.date) >>> >>> >>> >>> On Saturday, 15 December 2012 08:43:35 UTC-6, Mamisoa Andriantafika >>> wrote: Hi, I have this db model: db.define_table('patients', Field('name', 'string', length=32), Field('firstname', 'string', length=32), Field('dob', 'date'), format='%(name)s') db.define_table('dataset1', Field('date', 'date', length=32), Field('param1', 'string', length=50), Field('param2', 'string', length=50), Field('patient_id', db.patients, writable=False, readable=False)) db.define_table('dataset2', Field('date', 'date', notnull=True), Field('test1', 'text'), Field('patient_id', db.patients, writable=False, readable=True)) I'd like to show in one view, for 1 patient_id, all the corresponding dataset1 and dataset2 ordered by date. What query should I use? Do I have to use an intermediate table 'history' to record each activity in dataset1/2 to get a result? Thanks for help. >>> --
[web2py] Re: Beware auth.enable_record_versioning
It appears to be fixed in trunk. I copied my entire app into a new directory. created a copy of the original db, data included. used appadmin to do fake migrates on all tables. commented out the enable_record_versioning in all model files. Turned off fake migrate. stopped and restarted the server (on my system rocket hangs after some kinds of model changes.) opened up appadmin on all affected applications - no errors. removed the comment to re-enable versioning again no problems with appadmin on affected apps. Since I copied the database into a new db, the tables with names like attachments_archive_archive were still present. It did not create any tables with names like attachments_archive_archive_archive. So I call it fixed. On Friday, December 21, 2012 1:20:03 AM UTC-5, Massimo Di Pierro wrote: > > This helped me a lot understand the problem. I believe I have a fix in > trunk. Can you please check if the problem is indeed solved? > > On Thursday, December 20, 2012 1:21:21 PM UTC-6, Cliff Kachinske wrote: >> >> To enable archiving, I added enable_record_versioning(db) = True to my >> models files. >> >> I encountered the problems described in the two bug reports I submitted >> today on Google code. >> >> At one point I thought it would help with isolating the problem if I >> turned off versioning, so I commented out the line enabling it. >> >> When I uncommented the line, I found tables with names like >> "products_archive_archive." These are archive tables for the archive >> tables. >> >> I suppose if I repeated the sequence I would have tables with names like >> "products_archive_archive_archive." >> >> On Thursday, December 20, 2012 10:05:25 AM UTC-5, Massimo Di Pierro wrote: >>> >>> I do not understand. Can you explain? >>> >>> On Thursday, 20 December 2012 08:11:42 UTC-6, Cliff Kachinske wrote: I just discovered that auth.enable_record_versioning will create archive tables for the archive tables if turned off and turned back on. Not acceptable. >>> --
[web2py] session.flash not working?
I have this very simple code: session.flash = T('The contest is still open to submissions.') session.foo = T('pooh') logger.debug('contest still open to submissions') redirect(URL('default', 'index')) on the default/index controller, I can see that session.foo is 'pooh', session.flash is None (as it should), BUT request.flash is also None. So no message gets flashed. This with the most recent development version of web2py (just fetched from github). Is the logic behind session.flash somehow broken? Luca --
[web2py] Re: session.flash not working?
I searched the code base, and I cannot find any place where an assignment like: response.flash = session.flash appears. Is this broken? On Friday, December 21, 2012 1:53:21 PM UTC-8, Luca wrote: > > I have this very simple code: > > session.flash = T('The contest is still open to submissions.') > session.foo = T('pooh') > logger.debug('contest still open to submissions') > redirect(URL('default', 'index')) > > on the default/index controller, I can see that session.foo is 'pooh', > session.flash is None (as it should), BUT request.flash is also None. > So no message gets flashed. This with the most recent development version > of web2py (just fetched from github). > Is the logic behind session.flash somehow broken? > > Luca > --
Re: [web2py] Re: session.flash not working?
On 21 Dec 2012, at 2:13 PM, Luca wrote: > I searched the code base, and I cannot find any place where an assignment > like: response.flash = session.flash appears. > Is this broken? It's in Session.connect: if self.flash: (response.flash, self.flash) = (self.flash, None) > > On Friday, December 21, 2012 1:53:21 PM UTC-8, Luca wrote: > I have this very simple code: > > session.flash = T('The contest is still open to submissions.') > session.foo = T('pooh') > logger.debug('contest still open to submissions') > redirect(URL('default', 'index')) > > on the default/index controller, I can see that session.foo is 'pooh', > session.flash is None (as it should), BUT request.flash is also None. > So no message gets flashed. This with the most recent development version of > web2py (just fetched from github). > Is the logic behind session.flash somehow broken? > --
[web2py] Re: Query results from 2 children tables from same parent ordered by date
If you only need one date, why not display just one date? On Friday, December 21, 2012 2:01:59 PM UTC-7, Mamisoa Andriantafika wrote: > > I have pb to show the coalesce date in view. > I tried; > > exams_mutex['COALESCE(dataset1.date,dataset1.date)'] > > but it is not working? > > Le jeudi 20 décembre 2012 23:40:15 UTC+1, Mamisoa Andriantafika a écrit : >> >> I finally found the solution using COALESCE to merge and order date >> columns: >> >> exams_mutex = db().select(db.dataset1.date.coalesce(db.dataset1.date), db >> .dataset1.ALL, db.dataset2.ALL, left=[db.dataset1.on(db.mutex.i==0),db. >> dataset2.on(db.mutex.i==1)], orderby=db.dataset1.date.coalesce(db. >> dataset2.date)) >> >> Mamisoa >> >> Le jeudi 20 décembre 2012 16:08:34 UTC+1, Massimo Di Pierro a écrit : >>> >>> Sorry I do not have a good solution at the moment. Can you open a ticket >>> about this so we'll will not forget. For now you may want to consider >>> creating a database view and selecting from the view. You would need to >>> create a model (readonly) to access the view. >>> >>> On Wednesday, 19 December 2012 16:19:33 UTC-6, Mamisoa Andriantafika >>> wrote: Best results to UNION I could have was using the mutex table trick: http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/ with this syntax: exams_mutex = db().select(db.dataset1.ALL, db.dataset2.ALL, left=[db.dataset1.on(db.mutex.i==0),db.dataset2.on(db.mutex.i==1)]) Two problems left: 1- how to merge the 2 date columns 2- how to order then by date SQL answer is there: http://stackoverflow.com/questions/8245630/mysql-combine-two-date-fields-and-then-order-by SELECT [some info], GREATEST( ticket_date, ticket_history_date ) as latest_date FROM [tables and join] ORDER BY latest_date Is is possible using to process it using DAL? Le dimanche 16 décembre 2012 17:40:22 UTC+1, Mamisoa Andriantafika a écrit : > > Sorry I still get: "Cannot | incompatible Rows objects". > > I'll change the field name "date" you are very right. > > Le dimanche 16 décembre 2012 15:49:57 UTC+1, Massimo Di Pierro a > écrit : >> >> My bad. Thry this: >> >> fields1 = [db.dataset1.date, db.dataset1.param1, >> db.dateset1.patient_id] >> fields2 = [db.dataset2.date, db.dataset2.test1, >> db.dateset2.patient_id] >> rows = ( db(db.dataset1).select(*fields1) | >> db(db.dataset2).select(*fields2) ).sort(lambda row: row.date) >> >> Mind that having a column called "date" will result in major >> headaches in the future. >> >> On Sunday, 16 December 2012 03:15:46 UTC-6, Mamisoa Andriantafika >> wrote: >>> >>> Hi again, >>> >>> "|" seems not to work because the column numbers is different >>> between the 2 tables? >>> >>> >>> Le samedi 15 décembre 2012 20:23:44 UTC+1, Massimo Di Pierro a >>> écrit : If you have lots of records you may be able to do it with a database view but that may be db specific. If you don't have too many records you can do: rows = ( db(db.dataset1).select() | db(db.dataset2).select() ).sort(lambda row: row.date) On Saturday, 15 December 2012 08:43:35 UTC-6, Mamisoa Andriantafika wrote: > > Hi, > > I have this db model: > > db.define_table('patients', > Field('name', 'string', length=32), > Field('firstname', 'string', length=32), > Field('dob', 'date'), > format='%(name)s') > > db.define_table('dataset1', > Field('date', 'date', length=32), > Field('param1', 'string', length=50), > Field('param2', 'string', length=50), > Field('patient_id', db.patients, writable=False, > readable=False)) > > db.define_table('dataset2', > Field('date', 'date', notnull=True), > Field('test1', 'text'), > Field('patient_id', db.patients, writable=False, > readable=True)) > > I'd like to show in one view, for 1 patient_id, all the > corresponding dataset1 and dataset2 ordered by date. > > What query should I use? Do I have to use an intermediate table > 'history' to record each activity in dataset1/2 to get a result? > > Thanks for help. > --
Re: [web2py] raspberry pi
Kids are definitely jumping on this (and hackers and researchers etc - GPIO are easily interfaced with the RPi.GPIO module.). The response is really impressive, thanks in large part to the fact that people think of Python as the platform language. As From this article: http://www.raspberrypi.org/archives/2715 : "1. Given only brief exposure to the device and an opportunity to manipulate it, our technology club participation has skyrocketed from 1 student to 2/5 of our student population." That says something... For web2py to reach a higher potential on the platform however, it would need something like what is offered by webiopi ( http://code.google.com/p/webiopi/ ), or integrate with it. Francois -- www.pyptug.org - raspberry-python.blogspot.com On Saturday, December 15, 2012 7:13:44 PM UTC-5, Adi wrote: > > brings fantastic memories of early days with zx80 sinclair spectrum, > changing eprom for it, building cb radio stations, mono block amplifiers, > and so on :) hopefully kids jump on this, and spend some good times > programming... > > > On Sat, Dec 15, 2012 at 11:01 AM, Andrew W > > wrote: > >> I just bought one with the goal that its a clever "toy" that the kids to >> learn and have some fun at the same time, >> >> -- >> >> >> >> > > --
Re: [web2py] Interesting - Brython (python to javascript)
If you have had issues with these, you should report the bugs, because It does support string interpolation, modules and scope. List comprehension and the ternary operator have been added earlier this week. Classes is the main thing left. I started using brython in a limited deployment. I think the python module import loading thru ajax works well in my scenario, up to now, but I'll let this run for a little while more. François -- www.pyptug.org - raspberry-python.blogspot.com On Monday, December 17, 2012 2:08:41 AM UTC-5, viniciusban wrote: > > Brypthon doesn't support string interpolation, too. :-( > > On Sun, Dec 16, 2012 at 6:40 PM, Arnon Marcus > > > wrote: > > From what I saw, it does not support many fundamental features of > python, > > like class-inheritance (class, classMethod) modules (__import__, from, > as), > > scope (globals, nonlocal) and parsing (exec, eval). I think these are > > trivial for python developement, and should have some kind of > design-pattern > > transpiling specification that it follows. > > I think CoffeeScript actually has many of these already implemented, as > is > > quite pythonic already in much of it's syntax - and is much closer to > > JavaScript in the first place and already has tons of tools for > denugging, > > client/server-side automatic-transpiling, bundled up in > > minification/compression algorythms, etc... > > > > It's a cool idea, and pyjammas has existed for a long time now, but is > > anyone seriously thinking about using that in production? > > > > I think as long as browsers don't have some kind of cross-language VMs, > or > > at least a PVM built-in/plugin, than with all the excitement, it will > remain > > useless. > > I mean, how do you debug this? > > > > -- > > > > > > > --
[web2py] smartgrid button placement 'left' 'right', 'both'
I am trying to set the button placement of the "View", "Edit", "Delete" buttons in the smartgrid table to be 'left'. I am using: button_placement = 'left' in my controller when I set a smartgrid. It works in web2py 2.3.2 on my local machine, but won't work in 2.2.1 on our server. Is that setting not compatible with 2.2.1? If not, how can I do it in that version? --
[web2py] Re: 2.2.1 left joins broken?
It is correct in the sense it is what I intended it to be. You are proposing a change of behavior. I see where you are coming from. Please open a ticket about this. I would like to have some more opinions about this. Should None in is_active be treated as True? On Friday, 21 December 2012 14:02:25 UTC-6, Cliff Kachinske wrote: > > SQL is incorrect. > > is: "AND supplier_contacts.is_active = 'T'" > should be "AND (supplier_contacts.is_active = 'T' OR > supplier_contacts.is_active IS NULL)" > > On Friday, December 21, 2012 1:05:16 PM UTC-5, Massimo Di Pierro wrote: >> >> It looks to be the generated SQL is correct. It is possible you enabled >> record versioning and that added the common_filter is_active==True. Yet >> perhaps you have records with is_active=None and therefore they showed up >> before and not now. >> >> On Friday, 21 December 2012 10:50:13 UTC-6, Cliff Kachinske wrote: >>> >>> Salient details from two tables: >>> >>> db.define_table( >>> 'suppliers', >>> Field('name', length=256, required=True, notnull=True), >>> >>> >>> >>> db.define_table( >>> 'supplier_contacts', >>> Field('supplier_id', db.suppliers), >>> Field('first_name', length=32, required=True, notnull=True), >>> >>> >>> >>> The code below worked in 1.99.7. If the supplier had two contacts, it >>> would return two rows as expected, both with the same supplier data but >>> each with individual contact data. >>> >>> In 2.2.1 it returns no rows. >>> >>> def get_approved_suppliers(product_id): >>> >>> return db( >>> (db.product_suppliers.product_id==product_id) & >>> (db.product_suppliers.supplier_id==db.suppliers.id) >>> ).select( >>> db.suppliers.id, >>> db.suppliers.name, >>> # more supplier details omitted for brevity, >>> db.supplier_contacts.id, >>> db.supplier_contacts.first_name, >>> # contact details omitted for brevity. >>> left = db.supplier_contacts.on( >>> db.supplier_contacts.supplier_id==db.suppliers. >>> id >>> ) >>> ) >>> >>> >>> This is the query as shown by db._lastsql. (Broken into chunks for >>> readability) >>> >>> SELECT suppliers.id, suppliers.name, suppliers.address, suppliers. >>> address_2, suppliers.city, suppliers.state, suppliers.zip, suppliers. >>> land_line, suppliers.fax, suppliers.email, >>> suppliers.website,supplier_contacts >>> .id, supplier_contacts.first_name, >>> supplier_contacts.middle_name,supplier_contacts >>> .last_name, supplier_contacts.generation, >>> supplier_contacts.email,supplier_contacts >>> .mobile, supplier_contacts.land_line, supplier_contacts.fax >>> >>> FROM product_suppliers, suppliers >>> >>> LEFT JOIN supplier_contacts ON (supplier_contacts.supplier_id =suppliers >>> .id) >>> >>> WHERE (product_suppliers.product_id = 340) AND >>> (product_suppliers.supplier_id >>> = suppliers.id)) AND (product_suppliers.is_active = 'T')) AND (suppliers >>> .is_active = 'T')) AND (supplier_contacts.is_active = 'T')); >>> >>> >>> >>> >>> --
[web2py] How to check if plain text password matches with encrypted password in auth_user.password?
Hi, I have a password in plain text and I want to check if it matches with the crypted password in auth_user.password field. I have tried comparing auth_user.password with str(db.auth_user.password.validate(plain_password)[0]) with no success even when I know that the passwords match exactly. The problem seems to boil down to the fact that encryption of the same string results different encrypted strings. For example, >>> from gluon.validators import CRYPT, LazyCrypt >>> crypt = CRYPT() >>> str(LazyCrypt(crypt, 'mysecret')) 'pbkdf2(1000,20,sha512)$a2a2ca127df6bc19$77bb5a3d129e2ce710daaefeefef8356c4c827ff' >>> str(LazyCrypt(crypt, 'mysecret')) 'pbkdf2(1000,20,sha512)$a555a267249876fb$bc18f82b72a3a5ebce617f32d6abaa5c48734ab9' What would be the correct way to check if passwords match when they are given in encrypted form? Any hints are appreciated, Pearu --
Re: [web2py] How to check if plain text password matches with encrypted password in auth_user.password?
On 21 Dec 2012, at 5:12 PM, Pearu Peterson wrote: > Hi, > > I have a password in plain text and I want to check if it matches with the > crypted password in auth_user.password field. > > I have tried comparing auth_user.password with > str(db.auth_user.password.validate(plain_password)[0]) with no success even > when I know that the passwords match exactly. > > The problem seems to boil down to the fact that encryption of the same string > results different encrypted strings. For example, > >>> from gluon.validators import CRYPT, LazyCrypt > >>> crypt = CRYPT() > >>> str(LazyCrypt(crypt, 'mysecret')) > > 'pbkdf2(1000,20,sha512)$a2a2ca127df6bc19$77bb5a3d129e2ce710daaefeefef8356c4c827ff' > >>> str(LazyCrypt(crypt, 'mysecret')) > > 'pbkdf2(1000,20,sha512)$a555a267249876fb$bc18f82b72a3a5ebce617f32d6abaa5c48734ab9' > > What would be the correct way to check if passwords match when they are given > in encrypted form? You have to compare using the equality test in CRYPT, so compare CRYPT()(plaintext) == store_password (or something like that). You can't compare the resulting strings, because they have different (random) salt, at least by default they do. > > Any hints are appreciated, > Pearu > > > -- > > > --
Re: [web2py] How to check if plain text password matches with encrypted password in auth_user.password?
Thanks for the hint! The following expression works for me: db.auth_user.password.validate(plain_password) == (db(db.auth_user.id==auth.user_id).select ().first ().password, None) Thanks again, Pearu On Saturday, December 22, 2012 3:25:00 AM UTC+2, Jonathan Lundell wrote: > > On 21 Dec 2012, at 5:12 PM, Pearu Peterson > > > wrote: > > Hi, > > > > I have a password in plain text and I want to check if it matches with > the crypted password in auth_user.password field. > > > > I have tried comparing auth_user.password with > str(db.auth_user.password.validate(plain_password)[0]) with no success even > when I know that the passwords match exactly. > > > > The problem seems to boil down to the fact that encryption of the same > string results different encrypted strings. For example, > > >>> from gluon.validators import CRYPT, LazyCrypt > > >>> crypt = CRYPT() > > >>> str(LazyCrypt(crypt, 'mysecret')) > > > 'pbkdf2(1000,20,sha512)$a2a2ca127df6bc19$77bb5a3d129e2ce710daaefeefef8356c4c827ff' > > > > >>> str(LazyCrypt(crypt, 'mysecret')) > > > 'pbkdf2(1000,20,sha512)$a555a267249876fb$bc18f82b72a3a5ebce617f32d6abaa5c48734ab9' > > > > > > What would be the correct way to check if passwords match when they are > given in encrypted form? > > You have to compare using the equality test in CRYPT, so compare > CRYPT()(plaintext) == store_password (or something like that). You can't > compare the resulting strings, because they have different (random) salt, > at least by default they do. > > > > > Any hints are appreciated, > > Pearu > > > > > > -- > > > > > > > > > --
[web2py] Cron every 5 seconds.
Dear. I need refresh my index every 5 seconds. I think to use cron, so how i can call a controller (controller/myfunction) every 5 seconds? Regards. Fernando. --
Re: [web2py][outsource] Need a plugin that integrate jsTree or other tree plugin with closure table app
I try it, it works, but I am not sure if the JsTree is fully supported. I will, investigate on this in near future (in next 2 mounths maybe). Richard On Fri, Dec 21, 2012 at 3:10 PM, wwwgong wrote: > ch is based on Nested Set --
Re: [web2py] How to check if plain text password matches with encrypted password in auth_user.password?
On 21 Dec 2012, at 5:37 PM, Pearu Peterson wrote: > Thanks for the hint! > > The following expression works for me: > > db.auth_user.password.validate(plain_password) == > (db(db.auth_user.id==auth.user_id).select ().first ().password, None) Good. There's probably a shortcut in Auth, too, that would make it less verbose. A word to other readers: this is why the new format for stored passwords identifies the hash algorithm and includes the salt, which is (by default, anyway) randomly generated. When the user enters the plain password to log in, CRYPT can extract the algorithm and salt from the stored hash and hash the plaintext password with them, and then compare the result. In Pearu's test above, the == operation is implemented by CRYPT.__eq__ (actually LazyCrypt.__eq__, but it amounts to the same thing), using the approach I described. It's in gluon/validators.py if you're interested in the details. A nice side effect is that, if the comparison succeeds, you can migrate an old has to a newer, stronger one. That's pretty nice: you don't have to leave your MD5-hashed users hanging out to be hacked if someone manages to discover your hashes. (That's also a reason to use a global key for your hashes, which is not stored in the database, and not visible to someone who just manages to hack the database.) > > > Thanks again, > Pearu > > On Saturday, December 22, 2012 3:25:00 AM UTC+2, Jonathan Lundell wrote: > On 21 Dec 2012, at 5:12 PM, Pearu Peterson wrote: > > Hi, > > > > I have a password in plain text and I want to check if it matches with the > > crypted password in auth_user.password field. > > > > I have tried comparing auth_user.password with > > str(db.auth_user.password.validate(plain_password)[0]) with no success even > > when I know that the passwords match exactly. > > > > The problem seems to boil down to the fact that encryption of the same > > string results different encrypted strings. For example, > > >>> from gluon.validators import CRYPT, LazyCrypt > > >>> crypt = CRYPT() > > >>> str(LazyCrypt(crypt, 'mysecret')) > > > > 'pbkdf2(1000,20,sha512)$a2a2ca127df6bc19$77bb5a3d129e2ce710daaefeefef8356c4c827ff' > > > > >>> str(LazyCrypt(crypt, 'mysecret')) > > > > 'pbkdf2(1000,20,sha512)$a555a267249876fb$bc18f82b72a3a5ebce617f32d6abaa5c48734ab9' > > > > > > What would be the correct way to check if passwords match when they are > > given in encrypted form? > > You have to compare using the equality test in CRYPT, so compare > CRYPT()(plaintext) == store_password (or something like that). You can't > compare the resulting strings, because they have different (random) salt, at > least by default they do. > > > > > Any hints are appreciated, > > Pearu --
Re: [web2py] Interesting - Brython (python to javascript)
Thanks for letting us know. Are you one of the brython developers? On Friday, 21 December 2012 15:20:28 UTC-6, Francois Dion wrote: > > If you have had issues with these, you should report the bugs, because It > does support string interpolation, modules and scope. List comprehension > and the ternary operator have been added earlier this week. Classes is the > main thing left. I started using brython in a limited deployment. I think > the python module import loading thru ajax works well in my scenario, up to > now, but I'll let this run for a little while more. > > François > > -- > www.pyptug.org - raspberry-python.blogspot.com > > On Monday, December 17, 2012 2:08:41 AM UTC-5, viniciusban wrote: >> >> Brypthon doesn't support string interpolation, too. :-( >> >> On Sun, Dec 16, 2012 at 6:40 PM, Arnon Marcus >> wrote: >> > From what I saw, it does not support many fundamental features of >> python, >> > like class-inheritance (class, classMethod) modules (__import__, from, >> as), >> > scope (globals, nonlocal) and parsing (exec, eval). I think these are >> > trivial for python developement, and should have some kind of >> design-pattern >> > transpiling specification that it follows. >> > I think CoffeeScript actually has many of these already implemented, as >> is >> > quite pythonic already in much of it's syntax - and is much closer to >> > JavaScript in the first place and already has tons of tools for >> denugging, >> > client/server-side automatic-transpiling, bundled up in >> > minification/compression algorythms, etc... >> > >> > It's a cool idea, and pyjammas has existed for a long time now, but is >> > anyone seriously thinking about using that in production? >> > >> > I think as long as browsers don't have some kind of cross-language VMs, >> or >> > at least a PVM built-in/plugin, than with all the excitement, it will >> remain >> > useless. >> > I mean, how do you debug this? >> > >> > -- >> > >> > >> > >> > --
[web2py] Possible bug in JSONRPC in v2.3.2
Hi, I recently updated to v2.3.2 and noticed that my JSONRPC calls were failing with a message of "argument after ** must be a mapping, not str". After investigating some changes in the versions I noticed that in tools.py, in the serve_jsonrpc() function, the following line changed from: s = methods[method](*params) to s = methods[method](**params) I changed it back and everything works perfectly now. Is this a bug or am I doing something incorrectly? Thanks, Mike --
Re: [web2py] Possible bug in JSONRPC in v2.3.2
On Sat, Dec 22, 2012 at 3:57 AM, Mike D wrote: > s = methods[method](**params) I guess it should be s = methods[method](*args, **params) to be more flexible --
[web2py] Re: Query results from 2 children tables from same parent ordered by date
I actually need to display those coalesce dates out of SQLTABLE that I use in view. To be precise, I need to show in LI(date, LI(all parameters)). --