Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 286617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:39:09+00:00 2026-05-12T05:39:09+00:00

I’m having trouble using python function decorators in Google’s AppEngine. I’m not that familiar

  • 0

I’m having trouble using python function decorators in Google’s AppEngine. I’m not that familiar with decorators, but they seem useful in web programming when you might want to force a user to login before executing certain functions.

Anyway, I was following along with a flickr login example here that uses django and decorates a function to require the flickr login. I can’t seem to get this type of decorator to work in AppEngine.

I’ve boiled it down to this:

def require_auth(func):
    def check_auth(*args, **kwargs):
        print "Authenticated."
        return func(*args, **kwargs)
    return check_auth

@require_auth
def content():
    print "Release sensitive data!"

content()

This code works from the commandline, but when I run it in GoogleAppEngineLauncher (OS X), I get the following error:

check_auth() takes at least 1 argument (0 given) 

And I’m not really sure why…

EDIT to include actual code:
@asperous.us I changed the definition of content() to include variable arguments, is that what you meant?
@Alex Martelli, ‘print’ does work within AppEngine, but still a completely fair criticism.
Like I said, I’m trying to use the flickr login from the link above. I tried to put it into my app like so:

def require_flickr_auth(view):
    def protected_view(request,*args, **kwargs):
        if 'token' in request.session:
            token = request.session['token']
            log.info('Getting token from session: %s' % token)
        else:
            token = None
            log.info('No token in session')

        f = flickrapi.FlickrAPI(api_key, api_secret,
                                token=token, store_token=False)

        if token:
            # We have a token, but it might not be valid
            log.info('Verifying token')
            try:
                f.auth_checkToken()
            except flickrapi.FlickrError:
                token = None
                del request.session['token']

        if not token:
            # No valid token, so redirect to Flickr
            log.info('Redirecting user to Flickr to get frob')
            url = f.web_login_url(perms='read')
            print "Redirect to %s" % url

        # If the token is valid, we can call the decorated view.
        log.info('Token is valid')
        return view(request,*args, **kwargs)

    return protected_view

@require_flickr_auth
def content(*args, **kwargs):
    print 'Welcome, oh authenticated user!'

def main():
    print 'Content-Type: text/plain'
    content()

if __name__ == "__main__":
    main()

When I remove the @require_flickr_auth decoration, the string ‘Welcome …’ prints out just fine. Otherwise I get a big ugly AppEngine exception page with

type 'exceptions.TypeError': protected_view() takes at least 1 argument (0 given) 

at the bottom.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:39:09+00:00Added an answer on May 12, 2026 at 5:39 am

    You’re calling content() without any arguments, but the decorated version protected_view requires the request argument. Either add the argument to content or remove it from protected_view.

    If you’re getting that error with your simple version then I’d suspect that content is a class method as Alex suggested. Otherwise it looks like you’re telling it to expect at least one argument, then not supplying it any.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 208k
  • Answers 208k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since your data is so big, you should not try… May 12, 2026 at 9:38 pm
  • Editorial Team
    Editorial Team added an answer It is possible to do HTTP Basic Authentication in pure… May 12, 2026 at 9:38 pm
  • Editorial Team
    Editorial Team added an answer It is not possible to customise the alert through the… May 12, 2026 at 9:38 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.