I may have an older version, but I imagine that response.meta.keywords is
still just a string.
It may be c.keywords is type map?
I think type map would be an iterator which you can convert to a list.
Once you've used it, it's gone.
So, did you try something like on e of these?:
response.meta.keywords = ', '.join( c.keyword) ) # if it's a list
or
response.meta.keywords = ', '.join( list( c.keywords) ) # convert map to
a list
or
response.meta.keywords = ', '.join( [ i[0] for i in list(c.keyword)] ) #
it may be a list of lists
Sorry, but as you can see, my motto is simply 'try everything until it
works'!
You may wish to read up about the map function and iterators if this is a
new concept.
On Wednesday, 2 September 2020 at 16:16:09 UTC+1 lucas wrote:
> very simply, i'm trying to add keywords of type string to the
> response.meta.keywords, which used to be of type string and now its of type
> map, which exceptions out as above.
>
> i've also tried appending to the list like
> "response.meta.keywords.append("some string here")" and I've tried treating
> like a dictionary like, "response.meta.keywords['variable name'] = "keyword
> string"" and both blew up with an exception also. very strange change of
> response.meta.keywords.
>
> On Wednesday, September 2, 2020 at 10:39:37 AM UTC-4 villas wrote:
>
>> I'm not sure what you are doing exactly but you seem to have created a
>> map iterator. Maybe you could convert that to a list? You might be able
>> to work with it more easily. Something like this:
>> list( response.meta.keywords )
>>
>>
>>
>> On Wednesday, 2 September 2020 at 12:52:27 UTC+1 lucas wrote:
>>
>>> in fact, when i inspect the head of the final html in the browser, w2p
>>> doesn't return a string at all, in fact it returns a reference to an object:
>>>
>>> <meta name="keywords" content="<map object at 0x7f693a6a98e0>">
>>>
>>> On Tuesday, September 1, 2020 at 10:03:28 PM UTC-4 lucas wrote:
>>>
>>>> hello one and all,
>>>>
>>>> its been a while since i've been on here. that is a good sign for my
>>>> sites have been working great. love python and web2py. ok, so, i'm
>>>> slowing porting to python 3.8 from 2.7. still constant on web2py 2.20.4.
>>>> do i had some code under a controller that looks like:
>>>>
>>>> response.meta.keywords += (', '+c.keywords if c.keywords else "")
>>>>
>>>> and it errors saying that "TypeError(unsupported operand type(s) for
>>>> +=: 'map' and 'str')". after a bit of investigation i found
>>>> that response.meta.keywords is of type "map" instead of it used to being a
>>>> string. i'm obviously concatenating strings above.
>>>>
>>>> what the heck is type "map" and how's that work with keywords?
>>>>
>>>> lucas
>>>>
>>>
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/2b4aead7-6837-4f7a-bba4-631b802592ccn%40googlegroups.com.