TypeError: slice indices must be integers or None or have an __index__ method

740 views
Skip to first unread message

cadrentes

unread,
Nov 30, 2009, 10:53:33 AM11/30/09
to web2py-users
I'm not sure this is the right forum for this discussion, any guidance
in appreciated. After upgrading to 1.72.3 I get the following error
in one of my applications: "TypeError: slice indices must be integers
or None or have an __index__ method"

What should I be looking at to fix this. The bug report takes me to
the "if vars accepts" line.

Thanks
Richard

mdipierro

unread,
Nov 30, 2009, 11:41:11 AM11/30/09
to web2py-users
Can you show us a could of lines from the code that cause the error?
What version are you upgrading from?

cadrentes

unread,
Nov 30, 2009, 2:09:56 PM11/30/09
to web2py-users
Sure,
This is the "cookbook" application lightly modifed to take notes on
case followup. I believe I had it running on 1.67. I think this is
where it is hanging:
def new_sda():
form=SQLFORM(db.sda,fields=
['date','fidname','vetname','status','acctdue_at_513',\
'filenum','employee','comments'])
if form.accepts(request.vars,session):
redirect(URL(r=request,f='sdas'))
return dict(form=form)

Below is all of the code:

The Model:
import datetime; now=datetime.date.today()

db=SQLDB('sqlite://db.db')

db.define_table('identify',SQLField('fidname','string'))

db.define_table('current_status',SQLField('status','string'))

db.define_table('sda',
SQLField('fidname',db.identify),
SQLField('status',db.current_status),
SQLField('employee','string'),
SQLField('comments','text'),
SQLField('filenum', length=10),
SQLField('date','date',default=now),
SQLField
('acctdue_at_513','string',default='0000-00-00'),
SQLField('vetname','string'))

db.current_status.status.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB
(db,'current_status.status')]
db.identify.fidname.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB
(db,'identify.fidname')]
db.sda.filenum.requires=[IS_NOT_EMPTY()]
db.sda.comments.requires=IS_NOT_EMPTY()
db.sda.fidname.requires=IS_IN_DB
(db,'identify.fidname','identify.fidname')
db.sda.status.requires=IS_IN_DB
(db,'current_status.status','current_status.status')
db.sda.employee.requires=IS_NOT_EMPTY()

Controller:

@auth.requires_login()
def sdas():
if not session.counter:
session.counter = 1
else:
session.counter += 1

records=db(db.sda.fidname==request.vars.fidname)\
.select(
orderby=db.sda.filenum | ~db.sda.date)
form=SQLFORM(db.sda, fields=['fidname'])
return dict(form=form,records=records,counter=session.counter)

@auth.requires_login()
def show():
id=request.vars.id
sdas=db(db.sda.id==id).select()
if not len(sdas): redirect(URL(r=request,f='sdas'))
return dict(sda=sdas[0])

@auth.requires_login()
def new_sda():
form=SQLFORM(db.sda,fields=
['date','fidname','vetname','status','acctdue_at_513',\
'filenum','employee','comments'])
if form.accepts(request.vars,session):
redirect(URL(r=request,f='sdas'))
return dict(form=form)

def new_fiduciary():
form=SQLFORM(db.identify)
if form.accepts(request.vars,session):
redirect(URL(r=request, f='sdas'))
return dict(form=form)

@auth.requires_login()
def count():
results=db(db.sda.id>1).count()
if results < 1: redirect(URL(r=request,f='sdas'))
# sdas=db(db.sda.id==id).select()
# if not len(sdas): redirect(URL(r=request,f='sdas'))
# return dict(results=results, sda=sdas[0])
return dict(results=results)
> > Richard- Hide quoted text -
>
> - Show quoted text -

mdipierro

unread,
Nov 30, 2009, 3:26:32 PM11/30/09
to web2py-users
I cannot reproduce the problem. Can you post the complete traceback?
Which version of web2py are you running? which os?

mdipierro

unread,
Nov 30, 2009, 3:27:25 PM11/30/09
to web2py-users
I cannot reproduce the problem. Can you post the complete traceback?
Which web2py version? source or binary? which os?

On Nov 30, 1:09 pm, cadrentes <cadren...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages