Errors with the new version

8 views
Skip to first unread message

Kenneth

unread,
Apr 3, 2010, 8:44:44 PM4/3/10
to web2py-users
Last summer I started on an application that has been in use so far. I
havn´t upgraded it because there was no need for it.

Last month I started to do some serious updating of the code and the
first thing I did was upgrading web2py. Everything has been working
great so far, but two days ago I noticed something is wrong. I been
pulling my hair out trying to find out why the application is not
working. An hour ago i remembered that I indeed did an upgrade.

Old version is 1.65.4 and new version is the newest one.

Error message is:
File "gluon/sql.py", line 1428, in __allocate
raise Exception, "undefined record"

In paralell I´m still using the old version of the application so I
took the whole old application and copied it to an new directory. Made
a copy of the database och got the application to work. I tested that
it is working and then I applied to the new version Web2py on it (just
unzipped it and copied it on the old version). Application stopped
working.

Any ideas where to continue looking for the problem?


Kenneth

mdipierro

unread,
Apr 3, 2010, 9:37:31 PM4/3/10
to web2py-users
I need the complete traceback.

Kenneth Lundström

unread,
Apr 3, 2010, 9:49:49 PM4/3/10
to web...@googlegroups.com
Traceback (most recent call last):
File "gluon/restricted.py", line 173, in restricted
exec ccode in environment
File "/data/domains/live-kal.nudata.fi/applications/init/views/district/campaign.html", line 187, in <module>
{{=
A(XML('+ '), T('Add new personal reward'), XML(' &raquo;'), _href=URL(r=request,c='district',f='edit_reward', args=[district.id, campaign.id]))}}
File "gluon/globals.py", line 105, in write
self.body.write(xmlescape(data))
File "gluon/html.py", line 99, in xmlescape
return data.xml()
File "gluon/sql.py", line 1433, in __getattr__
self.__allocate()
File "gluon/sql.py", line 1428, in __allocate
raise Exception, "undefined record"
Exception: undefined record





--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.


mdipierro

unread,
Apr 3, 2010, 10:27:32 PM4/3/10
to web2py-users
the problem is that eaither district or campaign is a reference value
a record that does not exist.
Can you show us how they are defined?

On Apr 3, 8:49 pm, Kenneth Lundström <kenneth.t.lundst...@gmail.com>
wrote:


> Traceback (most recent call last):
>   File "gluon/restricted.py", line 173, in restricted
>     exec ccode in environment
>   File "/data/domains/live-kal.nudata.fi/applications/init/views/district/campaign.html",
> line 187, in <module>
>     {{=A(XML('+ '), T('Add new personal reward'), XML(' &raquo;'),
> _href=URL(r=request,c='district',f='edit_reward', args=[district.id,
> campaign.id]))}}
>   File "gluon/globals.py", line 105, in write
>     self.body.write(xmlescape(data))
>   File "gluon/html.py", line 99, in xmlescape
>     return data.xml()
>   File "gluon/sql.py", line 1433, in __getattr__
>     self.__allocate()
>   File "gluon/sql.py", line 1428, in __allocate
>     raise Exception, "undefined record"
> Exception: undefined record
>

> > web2py+un...@googlegroups.com<web2py%2Bunsu...@googlegroups.com>

hamdy.a.farag

unread,
Apr 4, 2010, 5:33:16 AM4/4/10
to web2py-users
I also have some comments on the latest version in repo

in auth.login()

captcha = self.settings.login_captcha or self.settings.captcha

this's had a bad effect for web applications having the login form in
the index page
This made the captcha appear in that form , the thing that had a bad
effect on the style

so what I suggest is that
you can have something like

self.settings.login_captcha_enabled = False
...................
..................
captcha = self.settings.login_captcha or self.settings.captcha if
self.settings.login_captcha_enabled else None

By doing so, every body is happy

*********

Another thing is that I found in

def del_membership(self, group_id, user_id=None):
"""
revokes membership from group_id to user_id
if user_id==None than user_id is that of current logged in
user
"""

group_id = group_id or self.id_group(role)
------------------> [role is not defined]


Did you mean :

def del_membership (self, group_id=None, user_id=None, role=None) ?

hamdy.a.farag

unread,
Apr 4, 2010, 6:07:50 AM4/4/10
to web2py-users
There's also another suggestion

The crud.update() forms doesn't display the 'record deleted message'
flash message in case of deleting records
instead it displays 'record updated'

in function update of the Crud class I suggest adding :

if form.accepts(request.post_vars, _session, formname=_formname,
onvalidation=onvalidation,
keepvalues=self.settings.keepvalues):

if form.vars.get('delete_this_record', False):
message = self.messages.record_deleted

mdipierro

unread,
Apr 4, 2010, 12:37:58 PM4/4/10
to web2py-users
Can you please email me a patch or the updated tools.py? Thanks

Massimo

Kenneth

unread,
Apr 4, 2010, 2:11:04 PM4/4/10
to web2py-users
Hello Massimo,

last night I sent you a mail about my problem with the new version,
did you get it? Just wanted to check if you got it.


Kenneth

hamdy.a.farag

unread,
Apr 5, 2010, 5:14:51 AM4/5/10
to web2py-users
Massimo, I sent you the patch
There's also another problem that I got confused about
when using crud.update in case of deleting a record
crud.settings.keepvalues = False is not working.
after deleting the record , form is not cleared

in fact it is not working either in case of updating record or
deleting it using crud.update()

mdipierro

unread,
Apr 5, 2010, 11:41:50 AM4/5/10
to web2py-users
another patch?

Joe Barnhart

unread,
May 9, 2010, 2:25:30 PM5/9/10
to web2py-users
I have the exact same problem. My database was created on an older
web2py and now I get this exception "undefined record" for a number of
my tables. Like you, my application still runs, but I'm unable to
administer it using the database admin tool because of the walkbacks.
Even the default auth tables such as db.auth_membership result in an
error when I try to view them in database admin!

This is all using the built-in sqllite database and standard automatic
"auth" tables. Here is an example of one of my own tables that now
fails to view in database admin:

db.define_table("signup",
SQLField("id_team_member", db.team_member, label="Team member"),
SQLField("id_meet_event", db.meet_event, label="Event"),
SQLField("best_time", "double"),
SQLField("course", "string", length=1, default='Y'),
SQLField("leg", "integer"),
SQLField("paid", "boolean", default=False))

Here is a complete traceback:

Traceback (most recent call last):
File "/Users/molly/Work/web2py/gluon/restricted.py", line 178, in
restricted
exec ccode in environment
File "/Users/molly/Work/web2py/applications/swimnutz/views/
appadmin.html", line 100, in <module>
File "/Users/molly/Work/web2py/gluon/globals.py", line 105, in write
self.body.write(xmlescape(data))
File "/Users/molly/Work/web2py/gluon/html.py", line 99, in xmlescape
return data.xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 521, in xml
(fa, co) = self._xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 512, in _xml
self.components])
File "/Users/molly/Work/web2py/gluon/html.py", line 99, in xmlescape
return data.xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 521, in xml
(fa, co) = self._xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 512, in _xml
self.components])
File "/Users/molly/Work/web2py/gluon/html.py", line 99, in xmlescape
return data.xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 521, in xml
(fa, co) = self._xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 512, in _xml
self.components])
File "/Users/molly/Work/web2py/gluon/html.py", line 99, in xmlescape
return data.xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 521, in xml
(fa, co) = self._xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 512, in _xml
self.components])
File "/Users/molly/Work/web2py/gluon/html.py", line 99, in xmlescape
return data.xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 521, in xml
(fa, co) = self._xml()
File "/Users/molly/Work/web2py/gluon/html.py", line 512, in _xml
self.components])
File "/Users/molly/Work/web2py/gluon/html.py", line 99, in xmlescape
return data.xml()
File "/Users/molly/Work/web2py/gluon/sql.py", line 1462, in
__getattr__
self.__allocate()
File "/Users/molly/Work/web2py/gluon/sql.py", line 1457, in
__allocate
raise Exception, "undefined record"
Exception: undefined record

Thadeus Burgess

unread,
May 9, 2010, 3:52:25 PM5/9/10
to web...@googlegroups.com
I have seen this quite a bit with my sqlite databases as well...

Basically, this is what is happening.

The referential integrity of your database is failing (IE: a FK links
to a record that does not exist).

This has happened many many times, and when I do a csv export of my
database, sure enough there are records referencing non-existant
records.

I have had this happen mostly on tables that contain self-references.

The problem is that SQLITE does not enforce referential integrity, so
there is a bug somewhere in the code that allows you to link to
non-existant records.

--
Thadeus

Joe Barnhart

unread,
May 9, 2010, 4:34:23 PM5/9/10
to web...@googlegroups.com
Hmmm...  Good point.  It's a production database and probably has developed some cruft over time.  What's the best way to clean it up?  Export it all to sql, edit it (or process it with a program) and re-import?  Or is there an easier way?

Thadeus Burgess

unread,
May 9, 2010, 8:18:29 PM5/9/10
to web...@googlegroups.com
Not sure. I have a production database that I take csv snapshots of
periodically using db.export_to_csv. I then use these and re-import
them into a local sqlite instance, so I can work off live data without
messing with live data :)

Usually the sqlite database works fine for a couple of days, and then
develops **this problem**, whereas my postgres production database
never has this issue.

I would first try to determine the problem record.... You can do this
be iterating through every record, and making sure its references are
in tact by determining if those records exist... if not, flag the
record.

Then look at your code to see if there is a hole that is letting this
problem happen.

Then you need to figure out what to do to repair it, its a big issue
because something belongs there, but you don't have any idea as to
what.

mdipierro

unread,
May 9, 2010, 9:00:18 PM5/9/10
to web2py-users


On May 9, 7:18 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> Not sure. I have a production database that I take csv snapshots of
> periodically using db.export_to_csv. I then use these and re-import
> them into a local sqlite instance, so I can work off live data without
> messing with live data :)
>
> Usually the sqlite database works fine for a couple of days, and then
> develops **this problem**, whereas my postgres production database
> never has this issue.
>
> I would first try to determine the problem record.... You can do this
> be iterating through every record, and making sure its references are
> in tact  by determining if those records exist... if not, flag the
> record.
>
> Then look at your code to see if there is a hole that is letting this
> problem happen.
>
> Then you need to figure out what to do to repair it, its a big issue
> because something belongs there, but you don't have any idea as to
> what.
>
> --
> Thadeus
>
> On Sun, May 9, 2010 at 3:34 PM, Joe Barnhart <joe.barnh...@gmail.com> wrote:
> > Hmmm...  Good point.  It's a production database and probably has developed
> > some cruft over time.  What's the best way to clean it up?  Export it all to
> > sql, edit it (or process it with a program) and re-import?  Or is there an
> > easier way?
>
> > On Sun, May 9, 2010 at 12:52 PM, Thadeus Burgess <thade...@thadeusb.com>
> > wrote:
>
> >> I have seen this quite a bit with my sqlite databases as well...
>
> >> Basically, this is what is happening.
>
> >> The referential integrity of your database is failing (IE: a FK links
> >> to a record that does not exist).
>
> >> This has happened many many times, and when I do a csv export of my
> >> database, sure enough there are records referencing non-existant
> >> records.
>
> >> I have had this happen mostly on tables that contain self-references.
>
> >> The problem is that SQLITE does not enforce referential integrity, so
> >> there is a bug somewhere in the code that allows you to link to
> >> non-existant records.
>
> >> --
> >> Thadeus
>
> >> On Sun, May 9, 2010 at 1:25 PM, Joe  Barnhart <joe.barnh...@gmail.com>

mdipierro

unread,
May 9, 2010, 9:06:02 PM5/9/10
to web2py-users
Looking at the traceback, you are trying to access a broken reference
from a view. Something like

{{=row.user.first_name}}

where row.user is user id and web2py needs a db query to find the
first_name of the user. If the user does not exit, web2py cannot
determine his first name.

What puzzles me is that in you case the view is
/Users/molly/Work/web2py/applications/swimnutz/views/appadmin.html

appadmin by default does not do anything like {{=row.user.first_name}}
but it may if a field has a represent= attribute and a field has one
if the table referred_by has a format= attribute.

So try this... for all define_table(...format="something") set
format=None. The error should go away and you should be able to see
what the records contain.
Reply all
Reply to author
Forward
0 new messages