Hi All,
      Why do I get this error Error - AttributeError: 'Rows' object
has no attribute '_db'. Please have a look at the code given below.
Whenever I hit the myfriends url, I get the below issue.
=============ERROR================
Ticket ID
127.0.0.1.2012-01-09.16-23-52.fb79b661-40af-4431-bdfa-7f1d5d3af482
 <type 'exceptions.AttributeError'> 'Rows' object has no attribute
'_db'

Version
 web2py™
(1, 99, 4, datetime.datetime(2011, 12, 14, 14, 46, 14), 'stable')

Python
Python 2.7.2: C:\Python27\python.exe


Traceback
1.2.3.4.5.6.7.8.9.10.11.12.
Traceback (most recent call last):
File "D:\WEB2PY\web2py\gluon\restricted.py", line 204, in
restricted    exec ccode in environment
File "D:/WEB2PY/web2py/applications/Build_Connect/controllers/
default.py", line 735, in <module>
File "D:\WEB2PY\web2py\gluon\globals.py", line 172, in <lambda>
self._caller = lambda f: f()
File "D:/WEB2PY/web2py/applications/Build_Connect/controllers/
default.py", line 707, in myfriends    csv=False, maxtextlength=128,
paginate=50)
File "D:\WEB2PY\web2py\gluon\sqlhtml.py", line 1455, in grid    db =
query._dbAttributeError: 'Rows' object has no attribute '_db'

=============

-------Here's the code---------
My Controller:

#This lists friends
def myfriends():
    db.friends.id.readable=False
    query = db((db.friends.reguserid==session.logged_in_user_id) &
(db.friends.status=="Friend")).select(db.friends.friend_name)
    print db._lastsql

    fields = (db.friends.id, db.friends.reguserid,
db.friends.friendid, db.friends.status, db.friends.friend_name,)
    headers ={'friends.id': 'ID',
              'friends.reguserid': 'ReguserID',
              'friends.friendid': 'FriendID',
              'friends.status': 'Status',
              'friends.friend_name': 'Friend Name',
              }

    #default_sort_order = [db.friends.friendid] #,
db.projects_posts.expected_start_date

    links = [lambda row: A(SPAN(_class='icon check'),'View
Profile',_class='positive button',_title='View this friends profile',
_href=URL("default","view_friend_profile",args=[row.friendid])),
             lambda row: A(SPAN(_class='icon cross'),'Remove
Friend',_class='negative button',_title='Remove from friend list',
_href=URL("default","remove_friend",args=[row.friendid]))]

    table = SQLFORM.grid( query=query, #fields=fields,
#headers=headers,  #orderby=default_sort_order,
                          user_signature=False, links=links,
create=False, searchable=False,
                          details=False, showbuttontext=False,
deletable=False, editable=False,
                          csv=False, maxtextlength=128, paginate=50)

    return dict(table=table)

#View Friends Profile
def view_friend_profile():
    session.myfriendid = request.args[0]
    #print session.myfriendid
    query = db(db.reguser.id==session.myfriendid).select()
    table = SQLFORM.grid(query=query)
    return dict(table= table)

#Remove Friend from Friends list
def remove_friend():
    session.myfriendid = request.args[0]
    db((db.friends.reguserid==session.logged_in_user_id) &
(db.friends.friendid==session.myfriendid) ).update(status='Rejected')
    #print db._lastsql
    return dict()


----x-----------------------

My View: (myfriends.html)

{{extend 'layout.html'}}
<h3>Friends List</h3>
<head>
<link rel="stylesheet" href="{{=URL(r=request,c='static',f='css/
css3buttons.css')}}" media="all" />
</head>
<hr />
{{=table}}
-----------x---------------------------------
My Table in db.py
reqstatus = ["Friend","Rejected","Sent"]
db.define_table('friends',
                Field('reguserid'),
                Field('friendid'),
                Field('status', requires=IS_IN_SET(reqstatus)),
                Field('friend_name'),
                )

----------------------------------------------------------------

I am using  - web2py1.99.4 , Win7 and python 2.7

Sincerely, Rahul D

Reply via email to