To try to triage the bug I did the following...
import os
import pygeoip
#gi = pygeoip.GeoIP(os.path.join(request.folder, 'private', 'GeoIP.dat'))
def get_country(row):
return "what?"
# -*- coding: utf-8 -*-
db.define_table('melodigram_play',
Field('melodigram_id', 'reference melodigram'),
Field('when_opened', 'datetime', default = request.now),
Field('from_where', 'string', default = request.client),
Field.Virtual('from_country', lambda row: get_country(row))
)
db.melodigram_play.melodigram_id.requires = IS_NOT_EMPTY()
db.melodigram_play.when_opened.requires = IS_NOT_EMPTY()
-----------------------------------------------------------------------------------------------
Basically I just remove everything and returned a text object.
This still gives me the same error.
File
"/home/encompass/Projects/melodigram/web2py/applications/melodigram/views/administration/browser.html",
line 101, in <module>
File "/home/encompass/Projects/melodigram/web2py/gluon/dal.py", line 7267, in
__getitem__
raise ae
AttributeError: 'Row' object has no attribute 'from_country'
On Wednesday, February 19, 2014 1:47:45 PM UTC+2, Marin Pranjić wrote:
>
> most likely get_country is failing for some reason
>
> Marin
>
>
> On Wed, Feb 19, 2014 at 9:40 AM, Jason Brower <[email protected]<javascript:>
> > wrote:
>
>> I have this in the model...
>> import uuid
>> import os
>> import pygeoip
>> gi = pygeoip.GeoIP(os.path.join(request.folder, 'private', 'GeoIP.dat'))
>> def get_country(row):
>> return gi.country_code_by_addr(row.from_where)
>> # -*- coding: utf-8 -*-
>> db.define_table('melodigram_play',
>> Field('melodigram_id', 'reference melodigram'),
>> Field('when_opened', 'datetime', default = request.now),
>> Field('from_where', 'string', default = request.client),
>> Field.Virtual('from_country', lambda row: get_country(row))
>> )
>> db.melodigram_play.melodigram_id.requires = IS_NOT_EMPTY()
>> db.melodigram_play.when_opened.requires = IS_NOT_EMPTY()
>>
>> I can insert data... but when I try to retrieve it, it tells me the row
>> doesn't exist:
>> <h2>From: {{=gram_details.from_where}} :
>> {{=gram_details.from_country}}</h2>
>> ----
>> gram_details.from_where has always worked.
>> gram_details.from_country doesn't work.
>>
>>
>> --
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
--
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/groups/opt_out.