I am defining this function.
db.define_table('person', Field('name'))
db.define_table('dog', Field('nickname'), Field('owner', db.person))
db.dog.owner.represent = lambda value: "%s" % db.owner[value].name
This works in sql.py
This does not work in dal.py
You said you made changes, I tested, works just fine on sql.py, and
has been for quite a while, however I get that stacktrace when I use
dal.py.
-Thadeus
On Wed, Apr 7, 2010 at 8:34 PM, mdipierro <[email protected]> wrote:
> I guess I do not understand. Who defined this represent function? is
> it not in your code? Are you saying this is a bug in sql.py?
>
> On Apr 7, 7:48 pm, Thadeus Burgess <[email protected]> wrote:
>> No.
>>
>> For dal.py to be accepted it has to work exactly like sql.py
>>
>> Therefore I cannot make ANY code changes if we want a new DAL.
>>
>> -Thadeus
>>
>> On Wed, Apr 7, 2010 at 5:31 PM, mdipierro <[email protected]> wrote:
>> > This
>>
>> > db.TableA.id_TableB.represent = lambda value: "%s" %
>> > db.TableB[value].name
>>
>> > should be
>>
>> > db.TableA.id_TableB.represent = lambda value: (db.TableB[value] or
>> > {}).get('name','anonymous')
>>
>> > On Apr 7, 1:36 pm, Thadeus Burgess <[email protected]> wrote:
>> >> Traceback (most recent call last):
>> >> File "/home/tburgess/Applications/web2py/gluon/restricted.py", line
>> >> 173, in restricted
>> >> exec ccode in environment
>> >> File
>> >> "/home/tburgess/Applications/web2py/applications/pms/views/default/index.html",
>> >> line 62, in <module>
>> >> <thead>
>> >> File
>> >> "/home/tburgess/Applications/web2py/applications/pms/models/common.py",
>> >> line 197, in <lambda>
>> >> db.TableA.id_TableB.represent = lambda value: "%s" %
>> >> db.TableB[value].name
>> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 2402,
>> >> in __getitem__
>> >> return self._db(self.id == key).select().first()
>> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 3276, in
>> >> select
>> >> return self._db._adapter.select(self._query,*fields,**attributes)
>> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 507, in
>> >> select
>> >> query = self.SELECT(query,*fields, **attributes)
>> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 433, in
>> >> SELECT
>> >> for field in self.db[table]:
>> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 2102,
>> >> in __getitem__
>> >> return dict.__getitem__(self, str(key))
>> >> KeyError: 'None'
>>
>> >> -Thadeus
>>
>> >> On Mon, Apr 5, 2010 at 6:00 PM, mdipierro <[email protected]> wrote:
>> >> > uploading fix. please check it. Thanks for testing this.
>>
>> >> > On Apr 5, 3:59 pm, Thadeus Burgess <[email protected]> wrote:
>> >> >> Traceback (most recent call last):
>> >> >> File "/home/tburgess/Applications/web2py/gluon/restricted.py", line
>> >> >> 173, in restricted
>> >> >> exec ccode in environment
>> >> >> File
>> >> >> "/home/tburgess/Applications/web2py/applications/pms/controllers/default.py",
>> >> >> line 278, in <module>
>> >> >> File "/home/tburgess/Applications/web2py/gluon/globals.py", line 96,
>> >> >> in <lambda>
>> >> >> self._caller = lambda f: f()
>> >> >> File
>> >> >> "/home/tburgess/Applications/web2py/applications/pms/controllers/default.py",
>> >> >> line 76, in duplicates
>> >> >> orderby=db.potentials.A
>> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 3258,
>> >> >> in select
>> >> >> return self._db._adapter.select(self._query,*fields,**attributes)
>> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 512, in
>> >> >> select
>> >> >> return self.parse(rows,self._colnames)
>> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 706, in
>> >> >> parse
>> >> >> (rid._table, rid._record) = (db[referee], None)
>> >> >> NameError: global name 'db' is not defined
>>
>> >> >> -Thadeus
>>
>> >> >> On Mon, Apr 5, 2010 at 3:01 PM, mdipierro <[email protected]>
>> >> >> wrote:
>> >> >> > try now
>>
>> >> >> > On Apr 5, 2:30 pm, Thadeus Burgess <[email protected]> wrote:
>> >> >> >> Now I get this for reference field
>>
>> >> >> >> Traceback (most recent call last):
>> >> >> >> File "/home/tburgess/Applications/web2py/gluon/restricted.py",
>> >> >> >> line
>> >> >> >> 173, in restricted
>> >> >> >> exec ccode in environment
>> >> >> >> File
>> >> >> >> "/home/tburgess/Applications/web2py/applications/pms/views/default/index.html",
>> >> >> >> line 84, in <module>
>> >> >> >> {{=db.table[column].represent(d.B[column])}}
>> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 2210,
>> >> >> >> in __getattr__
>> >> >> >> self.__allocate()
>> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 2203,
>> >> >> >> in __allocate
>> >> >> >> self._record = self._table[int(self)]
>> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 2384,
>> >> >> >> in __getitem__
>> >> >> >> return self._db(self.id == key).select().first()
>> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line
>> >> >> >> 3258, in select
>> >> >> >> return
>> >> >> >> self._db._adapter.select(self._query,*fields,**attributes)
>> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 512,
>> >> >> >> in select
>> >> >> >> return self.parse(rows,self._colnames)
>> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line 707,
>> >> >> >> in parse
>> >> >> >> colset[fieldname] = rid = Reference(value)
>> >> >> >> TypeError: int() argument must be a string or a number, not
>> >> >> >> 'NoneType'
>>
>> >> >> >> -Thadeus
>>
>> >> >> >> On Mon, Apr 5, 2010 at 2:20 PM, mdipierro <[email protected]>
>> >> >> >> wrote:
>> >> >> >> > I fixed the former. I did not fix the latter. It is a known
>> >> >> >> > problem
>> >> >> >> > with the new dal and one of the few things that needs to be ironed
>> >> >> >> > out: it does not like select('fieldname') only
>> >> >> >> > select(db.table['fieldname']). Not difficult to fix anyway.
>>
>> >> >> >> > On Apr 5, 2:13 pm, Thadeus Burgess <[email protected]> wrote:
>> >> >> >> >> I get this traceback when attempting to access a reference field.
>>
>> >> >> >> >> rows = db().select(db.table.ALL)
>> >> >> >> >> for r in rows:
>> >> >> >> >> r.id
>> >> >> >> >> r.title
>> >> >> >> >> r.reference_field.name
>> >> >> >> >> r.reference_field.description
>>
>> >> >> >> >> Traceback (most recent call last):
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/restricted.py",
>> >> >> >> >> line
>> >> >> >> >> 173, in restricted
>> >> >> >> >> exec ccode in environment
>> >> >> >> >> File
>> >> >> >> >> "/home/tburgess/Applications/web2py/applications/pms/views/default/index.html",
>> >> >> >> >> line 84, in <module>
>> >> >> >> >> {{=db.field[column].represent(d.B[column])}}
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line
>> >> >> >> >> 2210,
>> >> >> >> >> in __getattr__
>> >> >> >> >> self.__allocate()
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line
>> >> >> >> >> 2203,
>> >> >> >> >> in __allocate
>> >> >> >> >> self._record = self._table[int(self)]
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line
>> >> >> >> >> 2384,
>> >> >> >> >> in __getitem__
>> >> >> >> >> return self._db(self.id == key).select()._first()
>> >> >> >> >> AttributeError: 'Rows' object has no attribute '_first'
>>
>> >> >> >> >> I get this traceback from form = SQLFORM(db.mytable)
>>
>> >> >> >> >> Traceback (most recent call last):
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/restricted.py",
>> >> >> >> >> line
>> >> >> >> >> 173, in restricted
>> >> >> >> >> exec ccode in environment
>> >> >> >> >> File
>> >> >> >> >> "/home/tburgess/Applications/web2py/applications/pms/controllers/default.py",
>> >> >> >> >> line 278, in <module>
>> >> >> >> >> File
>> >> >> >> >> "/home/tburgess/Applications/web2py/applications/pms/models/plugin_compression.py",
>> >> >> >> >> line 28, in compress_response
>> >> >> >> >> d = d()
>> >> >> >> >> File
>> >> >> >> >> "/home/tburgess/Applications/web2py/applications/pms/controllers/default.py",
>> >> >> >> >> line 15, in index
>> >> >> >> >> return dict(hi='hi', form=SQLFORM(db.mytable))
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sqlhtml.py",
>> >> >> >> >> line
>> >> >> >> >> 688, in __init__
>> >> >> >> >> inp = self.widgets.multiple.widget(field, default)
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sqlhtml.py",
>> >> >> >> >> line
>> >> >> >> >> 211, in widget
>> >> >> >> >> return OptionsWidget.widget(field, value, **attributes)
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sqlhtml.py",
>> >> >> >> >> line
>> >> >> >> >> 187, in widget
>> >> >> >> >> options = requires[0].options()
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/validators.py",
>> >> >> >> >> line
>> >> >> >> >> 2227, in _options
>> >> >> >> >> options = self.other.options()
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/validators.py",
>> >> >> >> >> line
>> >> >> >> >> 385, in options
>> >> >> >> >> self.build_set()
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/validators.py",
>> >> >> >> >> line
>> >> >> >> >> 369, in build_set
>> >> >> >> >> records = self.dbset.select(*self.fields, **dd)
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line
>> >> >> >> >> 3258, in select
>> >> >> >> >> return
>> >> >> >> >> self._db._adapter.select(self._query,*fields,**attributes)
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line
>> >> >> >> >> 501, in select
>> >> >> >> >> query = self.SELECT(query,*fields, **attributes)
>> >> >> >> >> File "/home/tburgess/Applications/web2py/gluon/sql.py", line
>> >> >> >> >> 432, in SELECT
>> >> >> >> >> tablenames.append(f._tablename)
>> >> >> >> >> AttributeError: 'str' object has no attribute '_tablename'
>>
>> >> >> >> >> -Thadeus
>>
>> >> >> >> > --
>> >> >> >> > You received this message because you are subscribed to the
>> >> >> >> > Google Groups "web2py-users" group.
>> >> >> >> > To post to this group, send email to [email protected].
>> >> >> >> > To unsubscribe from this group, send email to
>> >> >> >> > [email protected].
>> >> >> >> > For more options, visit this group
>> >> >> >> > athttp://groups.google.com/group/web2py?hl=en.
>>
>> >> >> > --
>> >> >> > You received this message because you are subscribed to the Google
>> >> >> > Groups "web2py-users" group.
>> >> >> > To post to this group, send email to [email protected].
>> >> >> > To unsubscribe from this group, send email to
>> >> >> > [email protected].
>> >> >> > For more options, visit this group
>> >> >> > athttp://groups.google.com/group/web2py?hl=en.
>>
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups "web2py-users" group.
>> >> > To post to this group, send email to [email protected].
>> >> > To unsubscribe from this group, send email to
>> >> > [email protected].
>> >> > For more options, visit this group
>> >> > athttp://groups.google.com/group/web2py?hl=en.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups
>> > "web2py-users" group.
>> > To post to this group, send email to [email protected].
>>
>> ...
>>
>> read more »
>
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.