[web2py] Re: represent

2010-01-07 Thread mdipierro
Hi Gergo, appadmin has nothing to do with t2 and t2 was deprecated long ago. I guess you can still define db.post.represent but I am not sure what do you want to do with it. What behavior do you expect? Can you provide a concrete example? On Jan 7, 9:31 am, "KONTRA, Gergely" wrote: > Yes, AFAI

[web2py] Re: represent

2010-01-07 Thread mdipierro
Now I understand. Short answer. It cannot be done in the sense there is no API for it Long answer. It can be done this way: ### define table post and set the format ### based on a field that does not exist db.define_table('post', Field('title',length=256), Field('body','text',requires=IS

[web2py] Re: represent

2010-01-08 Thread mdipierro
Here is the problem. Perhaps you have a solution. format is used to represent a record in a reference as a select/ option. Probably you have many of these records and you only want to fetch columns that are necessary to build the representation. By using format='%(first_name)s %(last_name)s' web

[web2py] Re: represent

2010-01-08 Thread mdipierro
What do you want to do with it? Are you planning to fecth one record at the time for every record in all possible references? I would not recommend it. I am not saying no to your proposal of a represent function. I am just saying we need to think it over more. In the end what you want (and makes

[web2py] Re: represent

2010-01-08 Thread mdipierro
If I understand what you need, your problem is representing a record (not a specific field) in SELECT/OPTION when creating/updating a record in a different table that references this one. If this the case, the list of options is built by the IS_IN_DB validator. It looks at the format string, figu

[web2py] Re: represent

2012-03-11 Thread Alan Etkin
> db.Organization(targetID).name I'd use db.Organization[targetID].name Not sure the first syntax is supported, (tables should have a __call__ attribute for that purpose)

[web2py] Re: represent

2012-03-11 Thread Anthony
On Sunday, March 11, 2012 4:07:46 AM UTC-4, Annet wrote: > > 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_ta

[web2py] Re: represent

2012-03-11 Thread Anthony
> > > db.Organization(targetID).name > > I'd use db.Organization[targetID].name > > Not sure the first syntax is supported, (tables should have a __call__ > attribute for that purpose) Yes, the first syntax is supported -- it's just not the right query in this case. Anthony

[web2py] Re: represent

2012-03-11 Thread Anthony
> > > db.Organization(targetID).name >> >> I'd use db.Organization[targetID].name >> >> Not sure the first syntax is supported, (tables should have a __call__ >> attribute for that purpose) > > > Yes, the first syntax is supported -- it's just not the right query in > this case. > Note, the d

[web2py] Re: represent

2012-03-11 Thread Annet
Hi Alan and Anthony, Thanks for your replies. This solution partially solved the problem: db.NodeRelatedCard.targetID.represent = lambda targetID, row: db(db.Organization.nodeID == targetID).select().first().name In appadmin the targetID is now represented by the name of the organization, howeve

Re: [web2py] Re: represent

2010-01-07 Thread KONTRA, Gergely
Sure. db.py: db.define_table('post', Field('title',length=256), Field('body','text',requires=IS_NOT_EMPTY()), Field('author',db.auth_user), ) db.define_table('comment', Field('post',db.post,writable=False,readable=False), Field('author',db.auth_user,writable=False,readable=Fals

Re: [web2py] Re: represent

2010-01-08 Thread KONTRA, Gergely
Since the patch is about 2 lines of code, does it make sense to have a represent for tables, similar for fields, so that I could write something like: db.post.represent = lambda row: row['title'], which means the same as using format='%(title)s' on define_table? thx Gergo On Thu, Jan 7, 2010 at 2

Re: [web2py] Re: represent

2010-01-08 Thread KONTRA, Gergely
Well, then let the function accepts not a row, but an id, which is the pk of the row. On Fri, Jan 8, 2010 at 13:01, mdipierro wrote: > Here is the problem. Perhaps you have a solution. > > format is used to represent a record in a reference as a select/ > option. Probably you have many of these r

Re: [web2py] Re: represent

2010-01-08 Thread KONTRA, Gergely
First, I am not debugging the code, just browsing it, and found that: def sqlhtml_validators(field): """ Field type validation, using web2py's validators mechanism. makes sure the content of a field is in line with the declared fieldtype """ field_type, field_length = fiel

[web2py] Re: Represent problem.

2012-03-18 Thread Alan Etkin
Instead of the field representation, the row attribute returns the stored value of the record, as expected. Probably you can call the field represent functions for the required behavior if you are not using sqltable db.Edge.byNodeID.represent(row.byNodeID, row) db.Edge.ofNodeID.represent(row.ofNod

[web2py] Re: Represent problem.

2012-03-18 Thread Anthony
> > @auth.requires(auth.has_membership(HUB) or auth.has_membership(ADMIN)) > > Instead of the above, use: @auth.requires(lambda: auth.has_membership(HUB) or auth.has_membership(ADMIN)) That way, the two db hits for the has_membership calls will only happen when this specific function is acces

[web2py] Re: Represent problem.

2012-03-18 Thread Annet
Hi Alan and Anthony, @Alan, This: {{for row in rows:}} {{=db.Edge.byNodeID.represent(row.byNodeID, row)}} {{=db.Edge.ofNodeID.represent(row.ofNodeID, row)}} {{pass}} ... results in an empty element ... @Anthony, > Instead of the above, use: > > @auth.requires(lambda: auth.has_

[web2py] Re: represent() question.

2013-12-14 Thread Massimo Di Pierro
Perhaps you did not set a db.t_stores.f_store_name.represent = lambda On Saturday, 14 December 2013 12:02:08 UTC-6, Avi A wrote: > > 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_

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
I'm afraid I don't understand what you mean, but I didn't make one for the owner_rep and there it works? On Saturday, December 14, 2013 8:20:29 PM UTC+2, Massimo Di Pierro wrote: > > Perhaps you did not set a db.t_stores.f_store_name.represent = lambda > > On Saturday, 14 December 2013 12:02

[web2py] Re: represent() question.

2013-12-14 Thread Anthony
db.t_stores.created_by is a reference field, so by default it gets a "represent" attribute if the table to which it refers has a "format" attribute. The other fields presumably are not reference fields (nor other types of special fields that get default "represent" attributes), so they have no

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
thanks, why I try and use it is because when I use: {{for item in all_items:}} {{=item.created_by}} {{=item.f_item_category}} {{=item.f_item_store}} {{pass}} it renders: (2 items) 1 3 1 1 14 1 On Saturday, December 14, 2013 8:42:01 PM UTC+2, Anthony wrote: > > db.t_stores.created_by is a referenc

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
And i was trying what you answered me here once: https://groups.google.com/forum/?fromgroups=#!topic/web2py/U6-thwYLUVQ thanks. On Saturday, December 14, 2013 9:08:10 PM UTC+2, Avi A wrote: > > thanks, > why I try and use it is because when I use: > {{for item in all_items:}} > {{=item.created_by}

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
when i try the render() metohod I get: AttributeError: 'Rows' object has no attribute 'repr' So I'm probably on a different versioon? On Saturday, December 14, 2013 8:02:08 PM UTC+2, Avi A wrote: > > Hi, > I want to display item and use the represent() method to display reference > fields. >

[web2py] Re: represent() question.

2013-12-14 Thread Anthony
Did you do all_items.render() or all_items.repr()? On Saturday, December 14, 2013 2:12:31 PM UTC-5, Avi A wrote: > > when i try the render() metohod I get: > > AttributeError: 'Rows' object has no attribute 'repr' > > > So I'm probably on a different versioon? > > > On Saturday, December 14, 2013

[web2py] Re: represent() question.

2013-12-14 Thread Anthony
Are f_item_category and f_item_store reference fields? If so, they only get the default "represent" validator if (a) you do not explicitly specify a "requires" attribute and instead use the default validator, and (b) the referenced table has a "format" attribute. Otherwise, you will need to exp

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
I tried {{for item in all_items.render():}} On Saturday, December 14, 2013 9:48:57 PM UTC+2, Anthony wrote: > > Did you do all_items.render() or all_items.repr()? > > On Saturday, December 14, 2013 2:12:31 PM UTC-5, Avi A wrote: >> >> when i try the render() metohod I get: >> >> AttributeError: 'R

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
I see they both have notnull=True. (and format atribute). On Saturday, December 14, 2013 9:51:07 PM UTC+2, Anthony wrote: > > Are f_item_category and f_item_store reference fields? If so, they only > get the default "represent" validator if (a) you do not explicitly specify > a "requires" attr

[web2py] Re: represent() question.

2013-12-14 Thread Anthony
Can you show the whole traceback? I don't know why you'd be getting that error. Which version of web2py? On Saturday, December 14, 2013 2:53:11 PM UTC-5, Avi A wrote: > > I tried {{for item in all_items.render():}} > > On Saturday, December 14, 2013 9:48:57 PM UTC+2, Anthony wrote: >> >> Did you

[web2py] Re: represent() question.

2013-12-14 Thread Anthony
Looks like there was a bug in the .render() code up until 2.7.2, so you'll have to upgrade or edit dal.py to make it work. Even with the bug, I think you can instead do: {{for item in [all_items.render(i) for i in range(len(all_items))]:}} {{=item.created_by}} ... Anthony On Saturday, December

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
during this chat I upgraded to 2.8.2 and now i am stuck with some erro about: maxnum = MAXNFILES) in the admin/controller/default. :( On Saturday, December 14, 2013 10:24:40 PM UTC+2, Anthony wrote: > > Looks like there was a bug in the .render() code up until 2.7.2, so you'll > have to upgrad

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
allright, 2.8.2 is now working and all is rendered referenced as expected using that: {{for item in all_items.render():}} {{=item.created_by}} {{=item.f_item_category}} {{=item.f_item_store}} {{pass}} Thank you very much. On Saturday, December 14, 2013 10:28:50 PM UTC+2, Avi A wrote: > > during t

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
One more question please, The thing is the I need both to be rendered, the represented and NOT represented value, so I can use it in the args() for example to the user profile or store.? I tried back with the represent()method but I still get the: NoneType' object is not callable So if there is

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
these are probably different field. I will close this question for now...thanks. On Saturday, December 14, 2013 11:57:02 PM UTC+2, Avi A wrote: > > One more question please, > The thing is that I need both to be rendered, the represented and NOT > represented value, so I can use it in the args()

[web2py] Re: represent() question.

2013-12-14 Thread Avi A
For example: represnet(owner_id) On Saturday, December 14, 2013 11:57:02 PM UTC+2, Avi A wrote: > > One more question please, > The thing is that I need both to be rendered, the represented and NOT > represented value, so I can use it in the args() for example to the user > profile or store link

[web2py] Re: represent() question.

2013-12-14 Thread Anthony
You could always do something like: {{for i in range(len(all_items)):}} {{=A(all_items.render(i, fields=db.t_stores.owner_id).owner_id, _href=URL('default', 'stores', args=all_items[i].owner_id))}} {{pass}} Note, you don't have to specify the "fields" argument to .render(), but if you only

[web2py] Re: represent() question.

2013-12-15 Thread Avi A
great thanks. On Sunday, December 15, 2013 1:00:47 AM UTC+2, Anthony wrote: > > You could always do something like: > > {{for i in range(len(all_items)):}} > {{=A(all_items.render(i, fields=db.t_stores.owner_id).owner_id, > _href=URL('default', 'stores', args=all_items[i].owner_id))}} > {{pas

[web2py] Re: represent list:reference

2016-10-20 Thread leonardoporto
Up. Em terça-feira, 11 de setembro de 2012 18:35:25 UTC-3, Pepe Araya escreveu: > > 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'),

[web2py] Re: represent list:reference

2016-10-21 Thread Leonel Câmara
First you are getting the error because. db.publicaciones.autores.represent is not defined so it is None and hence not callable. That said. Here's a generic represent function you can use with list:reference fields. def represent_listref(table, *fields): def represent(values): resul

[web2py] Re: .represent not representing

2011-02-14 Thread DenesL
In theory it should work but you can get the same effect with format, try: db.define_table('adres', Field('straat'), format='%(straat)s' ) and remove the represent. On Feb 12, 10:04 am, Johann Spies wrote: > I get the following output : > > inwoner.idinwoner.v

[web2py] Re: represent in crud.select

2010-08-25 Thread mdipierro
fields should be fields=['friendship.id', 'friendship.to_user'], On Aug 25, 1:28 am, firedragon852 wrote: > 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, >                  

[web2py] Re: represent in form

2012-04-03 Thread Anthony
The "represent" attribute is used in SQLFORM, SQLTABLE, and can optionally be used when outputting CSV, but it isn't used every time you select and display a value. Can you show the code you are using to select and display the nodeID? Anthony On Tuesday, April 3, 2012 3:47:02 AM UTC-4, Annet w

[web2py] Re: represent in form

2012-04-03 Thread Annet
Hi Anthony, In db.py I defined these tables: db.define_table('Organization', Field('nodeID',db.Node,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False), Field('name',length=128,default='',notnull=True), ..., migrate=False) db.define_table('Address', F

[web2py] Re: represent in form

2012-04-04 Thread Anthony
Are you talking about the items in the select/options drop-down on forms? If so, that is controlled by the "label" argument (i.e., third argument) to the IS_IN_DB validator specified for the field. If you don't specify any validators for a given reference field and the referenced table includes

[web2py] Re: represent in form

2012-04-06 Thread Annet
Hi Anthony, I apologize for not giving a reply to your answer to my question. I am talking about the second bullet in http://web2py.com/books/default/chapter/29/6#Record-representation. - To set the db.othertable.person.represent attribute for all fields referencing this table. This mean

[web2py] Re: represent in form

2012-04-07 Thread Anthony
> > I am talking about the second bullet in > http://web2py.com/books/default/chapter/29/6#Record-representation. > >- To set the db.othertable.person.represent attribute for all fields >referencing this table. This means that SQLTABLE will not show references >by id but will use th

[web2py] Re: represent in form

2012-04-07 Thread Annet
Hi Anthony, Are you talking about a read-only form or an update form? On an update > form, it cannot use the alternative representation because the user must > enter the actual field value, not merely a transformed representation of it > (web2py has no general way of converting back from repres

[web2py] Re: represent for SQLFORM.grid

2015-06-09 Thread Anthony
The "represent" attribute doesn't apply to form widgets. For that, you will need to create a custom widget and specify the "widget" attribute of the Field. Anthony On Tuesday, June 9, 2015 at 4:51:59 PM UTC-4, i...@softmanufacture.com wrote: > > Hello, > > The represent works fine for grid vie

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

2011-10-14 Thread Massimo Di Pierro
documents is a list of IDs so you have to turn each one of them into a link. You can try: db.wbmaster.documents.represent = lambda value, row: SPAN(*[row.name]+ [A(v, _href = URL('download', args = v)) for v in value]) Hope I make sense. On Oct 14, 3:29 am, Johann Spies wrote: > This table > >

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

2011-10-14 Thread Massimo Di Pierro
My bad. Try this: def render_docs(ids,row): span = SPAN() for id in ids: doc = db.wbdocuments(id) if doc: span.append(A(doc.name,_href=URL('download',args=doc.file))) return span db.wbmaster.documents.represent = render_docs On Oct 14, 5:35 am, Johann Spies w

[web2py] Re: represent, format in view

2011-10-19 Thread DenesL
On Oct 19, 5:57 am, andrej burja wrote: > 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 it would be db.tag._format %row > row.tag > displays id > > is it different if format of tag

Re: [web2py] Re: .represent not representing

2011-02-14 Thread Richard Vézina
yes you are right, but I have problem with format some times don't know why... Format with that syntax : Field('myother_id','db.othertable'). And represent not work with : Field('myother_id',db.othertable) in case of crud.select, but works for crud.read... Richard On Mon, Feb 14, 2011 at 12:08

[web2py] Re: Represent: List indexing problem.

2014-02-24 Thread Brando
I solved this by inserting the data as json. This line now returns '324'. Field('username', represent = lambda x, row: x[0][1]), -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issue

[web2py] Re: represent in form field

2014-05-10 Thread Michael Beller
If you're using a custom form for input fields, you may need to invoke represent() explicitly. I found this in https://groups.google.com/forum/#!searchin/web2py/number$20format/web2py/Rn587zKW8MU/lzwVJw7naucJ : {{=db.table.column.represent(record.column, record)}} If you're using CRUD or Grid

[web2py] Re: represent in form field

2014-05-10 Thread 黄祥
thank you so much for the link e.g. work but not interactive db.product.price.widget = lambda field, value: SQLFORM.widgets.string.widget(field, format(value, ",d").replace(",", ".") ) what i mean is when user input in the form field it's not automatically add the thousand separator, thousand se

[web2py] Re: represent in form field

2014-05-10 Thread Anthony
On Saturday, May 10, 2014 2:11:04 PM UTC-4, Michael Beller wrote: > > If you're using a custom form for input fields, you may need to invoke > represent() explicitly. I found this in > https://groups.google.com/forum/#!searchin/web2py/number$20format/web2py/Rn587zKW8MU/lzwVJw7naucJ > : > > {{=db

[web2py] Re: represent in form field

2014-05-10 Thread 黄祥
i tried using jquery to face this, but it's only work for the first change, the others change is not effected, it seems like the twitter bootstrap enforce the form field (i guessed). e.g. *views/layout.html* *views/default/product.html* {{extend 'layout.html'}} {{=grid}} jQuery(document).rea

[web2py] Re: represent of list:reference field

2013-10-31 Thread Anthony
A list:reference field already gets a default "represent" attribute, as long as the referenced table has a "format" argument. However, the "represent" function (for any type of field) is only applied automatically in particular contexts (e.g., SQLTABLE, the grid, and read-only forms). In your c

[web2py] Re: represent of list:reference field

2013-10-31 Thread 黄祥
great, it works, thank you so much for your detail explaination anthony. btw, i found the others method in this forum something like : {{=', '.join('%s %s' % (lecturer.first_name, lecturer.last_name) for lecturer in header.course.lecturer)}} thanks and best regards, stifan -- Resources: - htt

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

2011-10-14 Thread Johann Spies
On 14 October 2011 11:14, Massimo Di Pierro wrote: > documents is a list of IDs so you have to turn each one of them into a > link. You can try: > > db.wbmaster.documents.represent = lambda value, row: SPAN(*[row.name]+ > [A(v, _href = URL('download', args = v)) for v in value]) > > Hope I make se

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

2011-10-14 Thread Johann Spies
On 14 October 2011 14:49, Massimo Di Pierro wrote: > My bad. Try this: > > def render_docs(ids,row): > span = SPAN() > for id in ids: > doc = db.wbdocuments(id) > if doc: > span.append(A(doc.name,_href=URL('download',args=doc.file))) > return span > > db.wbmaster.doc

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

2014-05-26 Thread Mandar Vaze
A Million Thanks for Johann (for asking the question) and Massimo (for providing the answer). Following is useful even after more than 3 years !!! Web2py rocks, and web2py community makes it even better :) -Mandar On Friday, October 14, 2011 6:56:07 PM UTC+5:30, Johann Spies wrote: > > > > On 1

[web2py] Re: represent in sqlform.grid and javascript

2017-10-04 Thread Dave S
I think you should show how you're setting up the datatables.net context. It looks like there is something about how pydal is called from that context, perhaps something that SQLFORM.grid initializes that is being missed in the JS setup. /dps On Wednesday, October 4, 2017 at 1:42:19 AM UTC

[web2py] Re: represent in sqlform.grid and javascript

2017-10-04 Thread 黄祥
*modules/test_grid.py* def list(table): query = (table.is_active == True) items = current.db(query).select(orderby = ~table.created_on).render() actions = [ {'is_item_action': lambda item: True, 'url': lambda item: URL('view', args = [item.id] ), 'icon': 'zoom-in', 'title': 'Vi

[web2py] Re: represent in sqlform.grid and javascript

2017-10-04 Thread 黄祥
for 1st problem, tried to print the value of the field just curious what SQLFORM.grid() does with this kind of data with represent, so that it can appears smoothly, while using another it's throw an error, any idea or hints? thanks and best regards, stifan -- Resources: - http://web2py.com -

[web2py] Re: Represent use wrong row id

2015-07-16 Thread Anthony
Definitely sounds odd. Can you upload a minimal app that reproduces the problem? On Thursday, July 16, 2015 at 5:47:52 PM UTC-4, icodk wrote: > > 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:

[web2py] Re: Represent use wrong row id

2015-07-17 Thread Anthony
It's a bug: https://groups.google.com/forum/#!topic/web2py/oui2tBIvcoM On Friday, July 17, 2015 at 4:27:34 PM UTC-4, Alex Glaros wrote: > > does the problem persist if you use vars instead of args? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web

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

2015-09-27 Thread ncl . biasi
Also after 4 years!!! Many, many thanks Nicola Il giorno martedì 27 maggio 2014 08:37:46 UTC+2, Mandar Vaze ha scritto: > > A Million Thanks for Johann (for asking the question) and Massimo (for > providing the answer). > Following is useful even after more than 3 years !!! > > Web2py rocks,

[web2py] Re: represent using data from multiple fields

2010-09-19 Thread mdipierro
This cannot be done with represent. The function is design to provide a representation for an individual field and there is no way to access other fields from within the function. On Sep 19, 10:52 pm, weheh wrote: > I know this issue has come up before but I'm having a hard time > finding the an

[web2py] Re: represent using data from multiple fields

2010-09-20 Thread weheh
That's too bad. It seems like the perfect thing to be able to do. I know I can pick apart the SQLTable in the view, but it would be so darn sweet to be able to do it in the represent view ... On Sep 20, 1:30 am, mdipierro wrote: > This cannot be done with represent. The function is design to prov

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

2012-04-19 Thread Anthony
db.EventList.endDate.represent = lambda v: v.strftime('%d/%m/%Y') if v else '' or db.EventList.endDate.represent = lambda v: v and v.strftime('%d/%m/%Y') or '' Anthony On Thursday, April 19, 2012 4:36:43 AM UTC-4, Annet wrote: > > I defined a table EventList: > > db.define_table('EventList',

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

2012-04-19 Thread Annet
Hi Johann and Anthony, Thanks for your replies. Problem solved. Kind regards, Annet.

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

2011-01-21 Thread web2py noob
bruno, as you say above is wrong. the workaround is: db.define_table('tablename', Field('fieldname',db.othertable, represent=lambda f: db.othertable[f].fieldname) ) best regards. On Jan 21, 2:15 pm, Bruno Rocha wrote: > It is a problem with SQLTABLE, detail tables is pure SQLTABLE, SOme peo

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

2011-01-26 Thread jclevy
Bruno Rocha writes: > > > 2011/1/21 web2py noob > > > > bruno, what you say above is wrong. the workaround is: > > db.define_table('tablename', >    Field('fieldname',db.othertable, represent=lambda f:db.othertable[f].fieldname)) > > best regards. I found that on of last changesets chan

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

2011-01-21 Thread Bruno Rocha
2011/1/21 web2py noob > bruno, as you say above is wrong. the workaround is: > > db.define_table('tablename', >Field('fieldname',db.othertable, represent=lambda f: > db.othertable[f].fieldname) > ) > > best regards. This is what I have working here: db.define_table('father', Fi

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

2011-01-27 Thread web2py noob
good job jclevy. i hope the fix for this could reach stable version soon. 2011/1/26 jclevy : > Bruno Rocha writes: > >> >> >> 2011/1/21 web2py noob >> >> >> >> bruno, what you say above is wrong. the workaround is: >> >> db.define_table('tablename', >>     Field('fieldname',db.othertable, repres

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Anthony
It should be args=row.id, not args=db.session.id (the former is the value of the id for the current record, and the latter is the actual id Field object). Anthony On Friday, March 6, 2015 at 1:37:22 PM UTC-5, Oliver Holloway wrote: > > In the following table, the session_name is represented as

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
When I try that, this error occurs: 'Row' object has no attribute 'id' On Friday, March 6, 2015 at 1:47:08 PM UTC-5, Anthony wrote: > > It should be args=row.id, not args=db.session.id (the former is the value > of the id for the current record, and the latter is the actual id Field > object).

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
This is the controller, in case that matters. @auth.requires_membership('coach') def show_list_of_sessions(): # get list of evaluations evaluations = SQLTABLE(db(db.sessions.session_type=='evaluation').select(db.sessions.session_name), headers=None, truncate=128

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Leonel Câmara
you need to write row.sessions.id You always need to be explicit in represents. -- 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

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
Hi, Leonel. When I do that, I get this error: 'Row' object has no attribute 'sessions' On Friday, March 6, 2015 at 2:02:57 PM UTC-5, Leonel Câmara wrote: > > you need to write row.sessions.id > > You always need to be explicit in represents. > -- Resources: - http://web2py.com - http://web2py.c

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Anthony
On Friday, March 6, 2015 at 2:02:57 PM UTC-5, Leonel Câmara wrote: > > you need to write row.sessions.id > > You always need to be explicit in represents. > You need to be explicit in virtual fields (i.e., include the table name), but I don't think that is the case with represent. I think the p

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
Added sessions.id to the select, same thing. Here's the table definition and the controller. The id does show up on the view page, but isn't passing as an arg. db.define_table('sessions', Field('program_name', 'string', requires=IS_IN_DB(db, db.programs.program_name)),

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Leonel Câmara
You have 'db' instead of 'row' in your 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 subscribed to the G

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Anthony
Is that the exact code, because you didn't change to args=row.id, and your second select is still missing the "id" field? Anthony On Friday, March 6, 2015 at 2:23:48 PM UTC-5, Oliver Holloway wrote: > > Added sessions.id to the select, same thing. Here's the table definition > and the controlle

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
Sorry, I've been trying various combinations. Here's what I've tried, none of them work. #db.sessions.session_name.represent = lambda session_name, row: A(row.session_name, _href=URL('demo', 'tests_for_this_eval',* args=sessions.id*)) # global name 'sessions' is not defined #db.sessions.sess

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
Hi, Anthony. I've posted the variations I've tried. As for the second select, I should have excised that because it's unimportant right now. On Friday, March 6, 2015 at 2:37:37 PM UTC-5, Anthony wrote: > > Is that the exact code, because you didn't change to args=row.id, and > your second select

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
I've caused some confusion with my typos. Here's the code. model db.define_table('sessions', Field('program_name', 'string', requires=IS_IN_DB(db, db.programs.program_name)), Field('session_type', 'string', requires=IS_IN_SET(['practice', 'evaluation'], zero=None)

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
Hey! I switched to vars and it worked :) Thank you to all of you who helped. db.sessions.session_name.represent = lambda session_name, r: A(r. session_name, _href=URL('demo', 'tests_for_this_eval', vars=dict(i=r.id))) > -- Resources: - http://web2py.com - http://web2py.com/book (Documentati

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Anthony
If vars=dict(i=r.id) works, then so will args=r.id. More specifically, if the latter generates an error saying the Row object has no attribute "id", then the former would also generate the same error, as "r" is the same Row object in both cases. I suspect you made some other change that made it

[web2py] Re: represent how to send row id in args

2015-03-06 Thread Oliver Holloway
Anthony, thanks, I swapped vars back in and that works now. You must be right, I must have made some other change, but I can't see what I did. At any rate, this is working now, and I regret if I've wasted anyone's time. On Friday, March 6, 2015 at 3:32:36 PM UTC-5, Anthony wrote: > > If vars=dic

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

2015-01-20 Thread Anthony
Hopefully the answer here will clarify things. On Tuesday, January 20, 2015 at 7:55:30 AM UTC-5, americandewd wrote: > > I have a form that was created by CRUD, I also update this form by CRUD. > > In another thread I was told by A

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

2015-01-20 Thread americandewd
I even tried simply adding "format='%(title)'" however I now get this error: got an unexpected keyword argument 'format' Is format no longer used for the field? It says in the book that I simply need to add it to the field to represent the data I want (instead of "name" I switched it to "title"