Re: [web2py] .represent

2018-01-28 Thread Anthony
On Sunday, January 28, 2018 at 3:28:22 AM UTC-5, Andrea Fae' wrote: > > Thank you Anthony. Where is it written that represent passes 2 positional > arguments in this way? > I guess it was meant to seem obvious from the examples. This is a common pattern with callback functions in Python. Feel

Re: [web2py] .represent

2018-01-28 Thread andfae
Thank you Anthony. Where is it written that represent passes 2 positional arguments in this way? 2018-01-27 14:26 GMT+01:00 Anthony : > On Friday, January 26, 2018 at 2:01:26 PM UTC-5, Andrea Fae' wrote: >> >> for me it's worst than before! >> what is other_table? Why you

Re: [web2py] .represent

2018-01-27 Thread Anthony
On Friday, January 26, 2018 at 2:01:26 PM UTC-5, Andrea Fae' wrote: > > for me it's worst than before! > what is other_table? Why you don't use row? I don't understand...I'm sorry > Python makes a distinction between positional and keyword arguments to functions. When web2py calls the represent

Re: [web2py] .represent

2018-01-26 Thread Andrea Fae'
for me it's worst than before! what is other_table? Why you don't use row? I don't understand...I'm sorry Il giorno venerdì 26 gennaio 2018 10:50:49 UTC+1, Massimiliano ha scritto: > > The first argument of the represent function is the field value. > So in the the second example the `id` arg is

Re: [web2py] .represent

2018-01-26 Thread Massimiliano
The first argument of the represent function is the field value. So in the the second example the `id` arg is the other_id value. Maybe the example could be more clear in this way: db.mytable.other_id.represent = lambda id, row: db.other_table[id].other_field On Fri, Jan 26, 2018 at 10:24 AM,

[web2py] .represent

2018-01-26 Thread Andrea Fae'
"Represent" from web2py book But what exactly are the relationship between "other_id" and "is" in the second example? And in the third from what is get the variable "value"? Thank you .represent can be None or can point to a function that takes a field value and returns an alternate

[web2py] represent in sqlform.grid and javascript

2017-10-04 Thread 黄祥
*modules/test_field_constructor.py* represent_reference_0 = lambda value, field: \ A('%s, %s, %s' % (field.address.street, field.address.city, field.address.country), _href="http://maps.google.com/maps?f=q=en=%s,+%s,+%s; % (field.address.street, field.address.city,

[web2py] represent for foreign key table

2016-09-06 Thread 黄祥
is it possible to have represent for foreign key table? e.g. db.define_table('address', Field('address', 'text'), Field('zip_code'), Field('city'), Field('country'), format = lambda r: '%s, %s, %s, %s' % (r.address, r.zip_code, r.city, r.country) ) def on_define_id_card(table): """

[web2py] Represent use wrong row id

2015-07-17 Thread Alex Glaros
does the problem persist if you use vars instead of args? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are

[web2py] Represent use wrong row id

2015-07-16 Thread icodk
I want to represent a field with a link to a function in an SQLFORM.smartgrid with reference to the row: db.place.mode.represent=lambda mode,row: A(mode,_href=URL( 'place_mode_change',args=[row.id],user_signature=True)) In the above expression the link A is constructed from the mode which is

[web2py] represent for SQLFORM.grid

2015-06-09 Thread info
Hello, The represent works fine for grid view but I need to apply represent function for the add, edit forms. db.product.price.represent = lambda x, row: current.currency.format_price(x) Inside html template I use {{=form}} as well as {{=form.custom.widget.price}} Thank you for the help. --

[web2py] represent how to send row id in args

2015-03-06 Thread Oliver Holloway
In the following table, the session_name is represented as a link. I want to pass session.id in args (rather than args=1 as you see below). How do I do that? I've tried various ways to say args=db.sessions.id, and it's as if the sessions.id value is not being picked up.

[web2py] Represent not working properly, behavior I am experiencing is not documented. Is this a bug?

2015-01-20 Thread americandewd
I have a form that was created by CRUD, I also update this form by CRUD. In another thread I was told by Anthony about a field widget controlling what is seen (he stated this is for: read-only forms, SQLTABLE, SQLFORM.grid, and when calling rows.render()) however per the book it says that to

[web2py] represent in form field

2014-05-09 Thread 黄祥
hi, is it possible to make represent work in form field? e.g. db.product.price.represent = lambda price, field: format(price, ,d).replace(,, .) this work only in view, not in the form field, my expectation is when user input the price in input field they will have . for thousand separated,

[web2py] represent and links in smartgrid

2014-05-07 Thread 黄祥
hi, i use smartgrid with links and have a represent for that table. when the links is clicked it returned an error, so that i must make a condition for that. e.g. *models/db.py* # on_define_shop def on_define_shop(table): # represent * if 'shop' in request.function :* table.website.represent =

[web2py] Represent: List indexing problem.

2014-02-24 Thread Brando
I am parsing data out of files and inputting this data into a sqlite db. One file may have multiple username entries. The data looks something like this: [['tom', 324],['dick', 246],['harry', 112]] The first item in each list is obviously the name. The second line is the line number (i

Re: [web2py] represent on grid that link to another grid

2014-02-10 Thread 黄祥
thank you so much for your pointers, richard. best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you

Re: [web2py] represent on grid that link to another grid

2014-02-09 Thread Richard Vézina
It may be also permission issue? Richard On Fri, Feb 7, 2014 at 7:54 PM, 黄祥 steve.van.chris...@gmail.com wrote: hi, is it possible to have represent on grid that link to another grid? e.g. table.supplier.represent = lambda supplier, field: \ A(supplier.name, _title=T(View Supplier),

Re: [web2py] represent on grid that link to another grid

2014-02-09 Thread Richard Vézina
Or as you mention the signature that you can pass with URL : http://web2py.com/books/default/chapter/29/04/the-core#Digitally-signed-urls Hope it helps Richard On Sun, Feb 9, 2014 at 1:46 PM, Richard Vézina ml.richard.vez...@gmail.comwrote: It may be also permission issue? Richard On

[web2py] represent on grid that link to another grid

2014-02-07 Thread 黄祥
hi, is it possible to have represent on grid that link to another grid? e.g. table.supplier.represent = lambda supplier, field: \ A(supplier.name, _title=T(View Supplier), _target=_blank, _href=URL('report','report_supplier', args = ['supplier', 'view', 'supplier', field.supplier]) ) i've

[web2py] represent() question.

2013-12-14 Thread Avi A
Hi, I want to display item and use the represent() method to display reference fields. def home(): all_items = db(db.t_items).select() owner_rep = db.t_stores.created_by store_rep = db.t_stores.f_store_name category_rep = db.t_categories.f_category_name return dict(all_items =

[web2py] represent of list:reference field

2013-10-31 Thread 黄祥
hi, is there a way to have represent of list:reference field? e.g. models db.define_table('book', Field('title'), Field('cover', 'upload'), format = '%(title)s') db.define_table('course', Field('course_name'), Field('description', 'text'), Field('book', 'list:reference book'),

[web2py] represent list:reference

2012-09-11 Thread Pepe Araya
Hello, I need to display the format value of the referenced table in a list:reference and not the list of ids. I have these tables: db.define_table('personas', Field('nombres'), Field('apellidos'), format='%(nombres)s %(apellidos)s') db.define_table('publicaciones', Field('titulo'),

Re: [web2py] .represent in case of empty field

2012-04-20 Thread Anthony
Try db.EventList.startDate.represent = lambda v: v.strftime('%d/%m/%Y') or None Note, that will still generate an error if v is None -- you have to first check for v before applying the strftime method to it. Anthony

[web2py] .represent in case of empty field

2012-04-19 Thread Annet
I defined a table EventList: db.define_table('EventList', Field('nodeID','reference Node',default='',notnull=True,ondelete='CASCADE',writable=False,readable=False), Field('summary',length=128,default='',notnull=True), Field('startDate',type='date'), Field('endDate',type='date'),

Re: [web2py] .represent in case of empty field

2012-04-19 Thread Johann Spies
On 19 April 2012 10:36, Annet anneve...@googlemail.com wrote: db.EventList.startDate.represent = lambda v: v.strftime('%d/%m/%Y') Is there a way to solve this problem? Try db.EventList.startDate.represent = lambda v: v.strftime('%d/%m/%Y') or None Regards Johann -- Because

[web2py] represent in form

2012-04-03 Thread Annet
In db.py I have a table Address which references a table Organization to display the organization name rather then the nodeID I set a validator: db.Address.nodeID.represent=lambda nodeID, row: db(db.Organization.nodeID==nodeID).select().first().name In 'database db select' Address.nodeID is

[web2py] Represent problem.

2012-03-18 Thread Annet
The table in db.py db.define_table('Edge', Field('hubID',db.Hub,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False), Field('byNodeID',db.Node,default='',notnull=True,ondelete='RESTRICT'), Field('ofNodeID',db.Node,default='',notnull=True,ondelete='CASCADE'), ...

[web2py] represent

2012-03-11 Thread Annet
In db.py I have: db.define_table('Node', Field('createdOn',type='datetime',writable=False,readable=False), Field('modifiedOn',type='datetime',writable= False,readable=False), migrate=False) db.define_table('Organization',

Re: [web2py] Represent - redirect

2012-01-17 Thread Mathias Van Daele
Thanks !! Op 17 januari 2012 00:44 schreef Anthony abasta...@gmail.com het volgende: On Monday, January 16, 2012 4:47:01 PM UTC-5, Mathias Van Daele wrote: Thanks for answer Johann. But how can I catch the value of args in the concerned function ? args from the URL are always in

Re: [web2py] Represent - redirect

2012-01-16 Thread Johann Spies
On 15 January 2012 22:49, Mathias Van Daele mathias.v.da...@gmail.comwrote: Hello, I have a select crud, with a URL in the column id. If I click 'edit', I should be redirected to a page, where I can update the concerned contact_part record. (as in a grid) What should I put between the

Re: [web2py] Represent - redirect

2012-01-16 Thread Mathias Van Daele
Thanks for answer Johann. But how can I catch the value of args in the concerned function ? Thanks Op 16 januari 2012 13:15 schreef Johann Spies johann.sp...@gmail.com het volgende: On 15 January 2012 22:49, Mathias Van Daele mathias.v.da...@gmail.comwrote: Hello, I have a select crud,

Re: [web2py] Represent - redirect

2012-01-16 Thread Anthony
On Monday, January 16, 2012 4:47:01 PM UTC-5, Mathias Van Daele wrote: Thanks for answer Johann. But how can I catch the value of args in the concerned function ? args from the URL are always in request.args, so in the edit_akb_country() function, the id would be in request.args(0). See

[web2py] Represent - redirect

2012-01-15 Thread Mathias Van Daele
Hello, I have a select crud, with a URL in the column id. If I click 'edit', I should be redirected to a page, where I can update the concerned contact_part record. (as in a grid) What should I put between the URL brackets ? _href=URL() How do I pass the selected record ? My code :

[web2py] represent, format in view

2011-10-19 Thread andrej burja
requires = IS_IN_DB(db,'tag.id',db.tag._ format,multiple=True) displays format of tag in dropdown while editing how to display format in view. doing row.tag displays id is it different if format of tag is lambda function? andrej

[web2py] Represent, list:reference, upload-field

2011-10-14 Thread Johann Spies
This table db.define_table(wbdocuments, Field(name, label = Document name), Field(file, upload, label = Download), format = '%(name)s') is linked in another table: db.define_table('wbmaster', Field('documents',

Re: [web2py] .represent = ... in left join

2011-04-06 Thread Johann Spies
On 5 April 2011 15:51, Richard Vézina ml.richard.vez...@gmail.com wrote: About zero option, search in page for zero : http://www.web2py.com/book/default/chapter/07 http://www.web2py.com/book/default/chapter/07There is some explanation near IS_IN_SET... Thanks. I found it. Johann --

Re: [web2py] .represent = ... in left join

2011-04-05 Thread Johann Spies
On 4 April 2011 16:11, Richard Vézina ml.richard.vez...@gmail.com wrote: Are course_week1 and course_week2 not null?? No. If not you need ...requires=IS_NULL_OR(IS_IN_DB(your requires) and in ...represent= you should use zero option (see book about that) or something like that :

Re: [web2py] .represent = ... in left join

2011-04-05 Thread Johann Spies
On 5 April 2011 09:16, Johann Spies johann.sp...@gmail.com wrote: Thanks! That solved the problem. I could not find something in the book about a 'zero option' though. Now .represent works on the screen but not in the CSV-output. I have used: {{ import cStringIO

Re: [web2py] .represent = ... in left join

2011-04-05 Thread Richard Vézina
About zero option, search in page for zero : http://www.web2py.com/book/default/chapter/07 http://www.web2py.com/book/default/chapter/07There is some explanation near IS_IN_SET... There maybe more detailed information somewhere else too... I don't use it in my code since it arrive after I start

Re: [web2py] .represent = ... in left join

2011-04-05 Thread Richard Vézina
I did not use export_to_csv for now... I just test it sometimes ago... But I guest you should define your .represent for stream table before try to apply them to your csv output... Hope it helps. Richard On Tue, Apr 5, 2011 at 3:27 AM, Johann Spies johann.sp...@gmail.com wrote: On 5 April

[web2py] .represent = ... in left join

2011-04-04 Thread Johann Spies
I want to get a proper representation of a field in the result of a left join but am struggling to do so. Here is a simplified version of the problem. db.define_table('courses', Field('week','integer', requires=IS_IN_SET([1,2]), widget =

Re: [web2py] .represent = ... in left join

2011-04-04 Thread Richard Vézina
Are course_week1 and course_week2 not null?? If not you need ...requires=IS_NULL_OR(IS_IN_DB(your requires) and in ...represent= you should use zero option (see book about that) or something like that : db.t_registration_form.course_week1.represent=\ lambda value: (value!=None and %(code)s

[web2py] represent and compute examples?

2011-03-06 Thread carlo
Working with web2py again after some time, I got acknowledged of the represent and compute attributes in DAL. They both seem very attractive to me but I would like to see some more examples of their usage because of the spare description in the book. Anyone could help? btw, I found out the great

Re: [web2py] .represent not representing

2011-02-14 Thread Richard Vézina
I have the same problem... I think there is a bug. Try to do this : 'db.adres' In your model inwoner. For me it solve the problem in old app (create in june or july that I transfert from one web2py version to an other since that time)... But not working if I am using a new freshly created app.

[web2py] .represent not representing

2011-02-12 Thread Johann Spies
I get the following output : inwoner.idinwoner.vaninwoner.adres1Spies1 the following code: db.define_table('adres', Field('straat')) db.define_table('inwoner', Field('van'), Field('adres', db.adres, requires =

[web2py] Represent not working in details on Powertable

2011-01-21 Thread Kenneth Lundström
Hello Bruno, I´m implementing powertables and can´t get it to show a reference field correctly. In my models: Field('f_customer', type='reference t_customer', label=T('Customer'), represent = lambda id: db.t_customer(id).f_internal_name), But when opening the Details it shows the

Re: [web2py] Represent not working in details on Powertable

2011-01-21 Thread Bruno Rocha
It is a problem with SQLTABLE, detail tables is pure SQLTABLE, SOme people identified a bug in SQLTABLE regarding references representation. It is showing the ID or sometines None for references. there is a workaround for that, using the represent direct on your model, try that.

[web2py] .represent and jqgrid

2010-10-29 Thread Johann Spies
The following works: db.teacher.id.represent = lambda id: A('edit',_href=URL(r=request,c='default',f='edit_teacher',args=str(id))) and the following not: db.school.id.represent = lambda id: db.school(id).name db.school.id is shown in jqgrid. How do I get the School name to show up in jqgrid?

[web2py] represent using data from multiple fields

2010-09-19 Thread weheh
I know this issue has come up before but I'm having a hard time finding the answer. My table has fields x and y. I want to do a represent like this: db.mytable.x.represent=lambda val: XML('div class=highlighted%s/ div'%val) if (x and not y) else val Well, obviously, the above won't work.

[web2py] represent in crud.select

2010-08-25 Thread firedragon852
If I do this: db.friendship.to_user.represent = lambda id: db.auth_user[id].nickname friends = crud.select(db.friendship, db.friendship.from_user == auth.user.id, fields=['id', 'to_user'], headers={'id':T('ID'), 'to_user':T('Friend')})