Does anyone know what would cause "represent" to be ignored?

On Monday, January 19, 2015 at 8:33:15 PM UTC-6, americandewd wrote:
>
> I have tried adding directly to the model: 
>
> represent = lambda f: db.category[f].title
>
> this did not work either, (also ignored)
>
> Any one have any ideas?  OR how I can troubleshoot this?
>
> On Monday, January 19, 2015 at 8:08:45 PM UTC-6, americandewd wrote:
>>
>> I noticed that in the places where I used represent it wasn't a dropdown 
>> selection plus I also made the field non-writable.  I cannot follow these 
>> conditions because it needs to be a list the user can select.
>>
>> Any ideas?
>>
>> On Monday, January 19, 2015 at 7:57:22 PM UTC-6, americandewd wrote:
>>>
>>> Ok I noticed partly where my error is:
>>> *row.title needs to be row.id <http://row.id>*
>>>
>>> I have used "represent" before and attempted it again here.  However it 
>>> is being completely ignored.  Specifically what I tried is not working and 
>>> I have used this many times before without problem.  The only difference 
>>> using it before was that the field was changed to be unwritable.
>>>
>>> Currently I tried to get represent to work in the same way I have used 
>>> before:
>>> formcontrol.category.represent = lambda f: db.category[f].title
>>>
>>> This is being completely ignored.
>>>
>>> Any ideas?
>>>
>>> On Monday, January 19, 2015 at 5:22:59 PM UTC-6, americandewd wrote:
>>>>
>>>> I have a dropdown list of categories I have created for users to select 
>>>> from, when I remove formcontrol.category.requires = 
>>>> IS_IN_SET(catwanted,zero=None) it shows the existing data the user has 
>>>> already chosen, when I put back the formcontrol.category.requires = 
>>>> IS_IN_SET(catwanted,zero=None) it does not show the data existing in the 
>>>> field.  The existing data was chosen from initial creation of the data in 
>>>> the same manner however if the user wants to go back and change this it is 
>>>> not showing what they had existing, instead the dropdown select has the 
>>>> first sorted item of the list as though they never had any data there (yet 
>>>> this record exists).
>>>>
>>>> I tried several things mentioned here and in the book, none of them 
>>>> showed the existing data.  The only thing that would show it is if I took 
>>>> out the "IS_IN_SET" with my list created from the actual category list in 
>>>> the DB.
>>>>
>>>> In my model I am creating a category list (Massimo helped with this 
>>>> awhile back):
>>>>
>>>> db.define_table('category', 
>>>>     Field('title'),
>>>>     Field('slug',requires=IS_SLUG(),compute=lambda row: IS_SLUG.urlify(
>>>> row.title)),
>>>>     Field('parent_id','reference category', default=None))
>>>>
>>>>
>>>>
>>>> In that list I have main categories that I do not want before I make a 
>>>> call to edit the form like so:
>>>> catwanted = []
>>>> notwanted = ['Dontwant1','Dontwant2','Dontwant3']
>>>> for row in db(db.category).select():
>>>> if row.title in notwanted:
>>>>     pass
>>>> else:
>>>>     catwanted.append(row.title)
>>>> catwanted.sort()
>>>>
>>>> When I call the form I put that list as a requirement:
>>>> formcontrol.category.requires = IS_IN_SET(catwanted,zero=None)
>>>>
>>>> The list shows up fine, the problem is that it does not show the 
>>>> existing data for that field, it shows the first sorted item.
>>>>
>>>> When I remove the 
>>>> formcontrol.category.requires = IS_IN_SET(catwanted,zero=None)
>>>> from the call it shows me the existing data in the field, however at 
>>>> this point I am not obviously removing the categories from the available 
>>>> options.
>>>>
>>>> Since the only way I can get it to show the existing value is by 
>>>> removing "formcontrol.category.requires = IS_IN_SET(catwanted,zero=None)" 
>>>> I 
>>>> am posting here to see if maybe this is just a weird bug because the data 
>>>> that exists in the field is not in the excluded list and I have other 
>>>> parts 
>>>> in which I do this except the only difference is that I do not exclude 
>>>> anything and it shows the existing value in the field.  This does not seem 
>>>> right to me for it to not want to show existing data that matches the data 
>>>> in the wanted list of items.
>>>>
>>>

-- 
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 Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to