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 4563756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:24:15+00:00 2026-05-21T18:24:15+00:00

I’m trying to retreive some OAuth information that I’ve stored using Datastore, but I’m

  • 0

I’m trying to retreive some OAuth information that I’ve stored using Datastore, but I’m getting this error when I’m instantiating my OAuthConsumer class:

TypeError: __init__() got an unexpected keyword argument 'consumer_secret'

This is also my first time experimenting with Namespace, and I’m wondering if that has something to do with it. The class is as follows:

creds = OAuthConsumer('google')

class OAuthConsumer(db.Model):
    '''the oauth consumer information'''
    consumer_key = db.StringProperty()
    consumer_secret = db.StringProperty()

    def __init__(self, service):
        namespace_manager.set_namespace(service)
        query = db.GqlQuery('SELECT * FROM OAuthConsumer')
        creds = query.get()
        self.consumer_key = creds.consumer_key
        self.consumer_secret = creds.consumer_secret

Here’s what I’ve got using Data Viewer:

credentials are blocked out

Any ideas as to what I’m doing wrong?

  • 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-21T18:24:16+00:00Added an answer on May 21, 2026 at 6:24 pm

    You’re overriding the __init__ method on a Datastore Model class, and you’re not passing the keyword arguments through to the parent constructor (or calling it at all!).

    As a general rule, you shouldn’t override the constructor of a Datastore Model class. It’s possible to do it right, but it’s tricky, and it’s far safer to provide a class method as a factory, like this:

    class OAuthConsumer(db.Model):
        '''the oauth consumer information'''
        consumer_key = db.StringProperty()
        consumer_secret = db.StringProperty()
    
        @classmethod
        def new(cls, service):
            namespace_manager.set_namespace(service)
            query = db.GqlQuery('SELECT * FROM OAuthConsumer')
            creds = query.get()
            return cls(consumer_key=creds.consumer_key, consumer_secret=creds.consumer_secret)
    
    creds = OAuthConsumer('google')
    

    Your code is more than a little odd for a couple of reasons, though:

    • When constructing a new instance, you fetch and copy the fields from another, (effectively) randomly selected instance of the same model!
    • You’re setting the namespace inside a constructor (or in the rewritten version, in a factory method). The namespace is a global setting, and you really shouldn’t do this inside a library method. You don’t set it back afterwards, either.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm trying to create an if statement in PHP that prevents a single post
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.