Re: [web2py] Virtual Fields not working on print.
Yes, that seems to do it, thanks. :) On Wed, Feb 19, 2014 at 3:58 PM, Anthony abasta...@gmail.com wrote: In virtual field functions, you must refer to the table name and field name within each row object, so: return gi.country_code_by_addr(row.melodigram_play.from_where) should be: return gi.country_code_by_addr(row.from_where) That doesn't explain the problem below, but I wonder if something else is going on there (e.g., is the app compiled, and you didn't re-compile after making the change?). As an aside, if you already have a function, no need to wrap it in a lambda -- just do: Field.Virtual('from_country', get_country) Anthony On Wednesday, February 19, 2014 7:32:41 AM UTC-5, Encompass solutions wrote: 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 enco...@gmail.com 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: h2From: {{=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 web2py+un...@googlegroups.com. 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 a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/2Shkz7T3cvQ/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Virtual Fields not working on print.
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: h2From: {{=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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Virtual Fields not working on print.
most likely get_country is failing for some reason Marin On Wed, Feb 19, 2014 at 9:40 AM, Jason Brower encomp...@gmail.com 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: h2From: {{=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 web2py+unsubscr...@googlegroups.com. 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Virtual Fields not working on print.
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 enco...@gmail.comjavascript: 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: h2From: {{=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 web2py+un...@googlegroups.com 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Virtual Fields not working on print.
In virtual field functions, you must refer to the table name and field name within each row object, so: return gi.country_code_by_addr(row.melodigram_play.from_where) should be: return gi.country_code_by_addr(row.from_where) That doesn't explain the problem below, but I wonder if something else is going on there (e.g., is the app compiled, and you didn't re-compile after making the change?). As an aside, if you already have a function, no need to wrap it in a lambda -- just do: Field.Virtual('from_country', get_country) Anthony On Wednesday, February 19, 2014 7:32:41 AM UTC-5, Encompass solutions wrote: 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 enco...@gmail.com 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: h2From: {{=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 web2py+un...@googlegroups.com. 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.