AttributeError: 'str' object has no attribute 'application'

777 views
Skip to first unread message

Johann Spies

unread,
Apr 18, 2012, 5:09:06 AM4/18/12
to web...@googlegroups.com
I have the following function in a module.  When I comment out the 'links' it works without a problem, but with the links active I get the error in the subject line:

def artikels(query = None):
    db
= current.db
   
if not query:
        query
= db.akb_articles.id > 0
                           
    links
= [lambda row: A(T('show article'), _href = URL(r = request, c = 'default',
                                                      f
= 'show_akb_article',
                                                      args
= row.id
                                                     
))]
    fields
= [db.akb_articles.title, db.akb_articles.primaryauthor,
              db
.akb_articles.authors,
              db
.akb_articles.journal, db.akb_articles.pubyear, db.akb_articles.url]    
   
   
    form
= SQLFORM.grid(query,
                        fields
= fields,
                       
orderby = db.akb_articles.title,
                        maxtextlength
= 90,
                        editable
= False, deletable = False,
                        details
= False,
                        searchable
= False,
                        links
= links,
                        ui
= 'jquery-ui')
   
return form

Why? 

Regards
Johann

Anthony

unread,
Apr 18, 2012, 11:12:49 AM4/18/12
to web...@googlegroups.com
Your links function calls URL with r=request -- is request defined as a string somewhere in the module before that function?

simon

unread,
Apr 18, 2012, 1:56:08 PM4/18/12
to web...@googlegroups.com
There is no "r" parameter for URL. Not sure what you are trying to pass. You already specify the controller and function.

Anthony

unread,
Apr 18, 2012, 2:53:40 PM4/18/12
to web...@googlegroups.com
On Wednesday, April 18, 2012 1:56:08 PM UTC-4, simon wrote:
There is no "r" parameter for URL. Not sure what you are trying to pass. You already specify the controller and function.

Yes, there is an "r" argument to URL -- it takes a request object and reads the current application, controller, and function from it if not provided explicitly.

Anthony 

simon

unread,
Apr 18, 2012, 3:11:39 PM4/18/12
to web...@googlegroups.com
So there is. That is handy. Not mentioned in the book!

Anthony

unread,
Apr 18, 2012, 3:33:58 PM4/18/12
to web...@googlegroups.com
On Wednesday, April 18, 2012 3:11:39 PM UTC-4, simon wrote:
So there is. That is handy. Not mentioned in the book!

In most cases, it's not necessary -- when you exclude "r", it defaults to current.request.

Anthony 

Cliff

unread,
Apr 18, 2012, 10:26:36 PM4/18/12
to web...@googlegroups.com
Should that not be current.request?


On Wednesday, April 18, 2012 5:09:06 AM UTC-4, Johann Spies wrote:

Johann Spies

unread,
Apr 19, 2012, 2:59:02 AM4/19/12
to web...@googlegroups.com
On 19 April 2012 04:26, Cliff <cjk...@gmail.com> wrote:
Should that not be current.request?


Yes!  Thanks Cliff.  Well spotted.

Regards
Johann

--
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Reply all
Reply to author
Forward
0 new messages