views:

283

answers:

2

New to app engine and django. I think this is an issue with my django install, which is 1.1.1, but I've also read that I can just use the django packaged with the app engine SDK.

Any help on why I'm getting this error when I test locally would be greatly appreciated.

The callback:

Variable Value
callback 
<class 'ourlat.main.views.SettingsPage'>
callback_args 
()
callback_kwargs 
{}
e 
TypeError('default __new__ takes no parameters',)
exc_info 
(<type 'exceptions.TypeError'>, TypeError('default __new__ takes no parameters',), <traceback object at 0x02201B48>)
exceptions 
<module 'django.core.exceptions' from 'C:\Documents and Settings\Jeremy Gordon\eclipse-workspace\ourlat\django\core\exceptions.pyc'>
middleware_method 
<bound method CommonMiddleware.process_request of <django.middleware.common.CommonMiddleware object at 0x021F5170>>
receivers 
[(<function _rollback_on_exception at 0x02063730>, None)]
request 
<WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{}, META:{'APPLICATION_ID': 'ourlat', 'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', 'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'localhost:8080', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.1 (KHTML, like Gecko) Chrome/5.0.335.1 Safari/533.1', 'PATH_INFO': u'/', 'PATH_TRANSLATED': 'C:\\Documents and Settings\\Jeremy Gordon\\eclipse-workspace\\ourlat\\main.py', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': u'', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', 'SERVER_PROTOCOL': 'HTTP/1.0', 'SERVER_SOFTWARE': 'Development/1.0', 'TZ': 'UTC', 'USER_EMAIL': '', 'USER_ID': '', 'USER_ORGANIZATION': '', 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x00B1F0B0>, 'wsgi.input': <cStringIO.StringI object at 0x022A0260>, 'wsgi.multiprocess': False, 'wsgi.multithread': False, 'wsgi.run_once': True, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}>
resolver 
<RegexURLResolver urls (None:None) ^/>
response 
None
self 
<django.core.handlers.wsgi.WSGIHandler object at 0x021F5790>
settings 
<django.conf.LazySettings object at 0x01E997B0>
urlconf 
'urls'
urlresolvers 
<module 'django.core.urlresolvers' from 'C:\Documents and Settings\Jeremy Gordon\eclipse-workspace\ourlat\django\core\urlresolvers.pyc'>

The error:

TypeError at /
default __new__ takes no parameters
Request Method: GET
Request URL: http://localhost:8080/
Exception Type: TypeError
Exception Value: 
default __new__ takes no parameters
Exception Location: C:\Documents and Settings\Jeremy Gordon\eclipse-workspace\ourlat\django\core\handlers\base.py in get_response, line 92
Python Executable: C:\Python25\python.exe
Python Version: 2.5.0
Python Path: ['C:\\Documents and Settings\\Jeremy Gordon\\eclipse-workspace\\ourlat', 'C:\\Program Files\\Google\\google_appengine', 'C:\\Program Files\\Google\\google_appengine\\lib\\antlr3', 'C:\\Program Files\\Google\\google_appengine\\lib\\django', 'C:\\Program Files\\Google\\google_appengine\\lib\\ipaddr', 'C:\\Program Files\\Google\\google_appengine\\lib\\webob', 'C:\\Program Files\\Google\\google_appengine\\lib\\yaml\\lib', 'C:\\Program Files\\Google\\google_appengine', 'C:\\Python25\\lib\\site-packages\\beautifulsoup-3.1.0.1-py2.5.egg', 'C:\\Python25\\lib\\site-packages\\django-1.1.1-py2.5.egg', 'C:\\Documents and Settings\\Jeremy Gordon\\eclipse-workspace\\ourlat\\ourlat', 'C:\\Program Files\\Google\\google_appengine', 'C:\\Program Files\\Google\\google_appengine\\lib\\webob', 'C:\\Program Files\\Google\\google_appengine\\lib\\yaml', 'C:\\Program Files\\Google\\google_appengine\\lib', 'C:\\Program Files\\Google\\google_appengine\\lib\\simplejson-2.0.9', 'C:\\Program Files\\Google\\google_appengine\\lib\\geopy', 'C:\\Program Files\\Google\\google_appengine\\lib\\BeautifulSoup-3.0.8', 'C:\\Documents and Settings\\Jeremy Gordon\\eclipse-workspace\\ourlat\\django', 'C:\\Python25', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\\lib\\site-packages\\setuptools-0.6c7-py2.5.egg', 'C:\\Python25\\lib\\site-packages\\simplejson-2.0.9-py2.5.egg', 'C:\\Python25\\Lib\\site-packages\\geopy-0.93dev_r0-py2.5.egg', 'C:\\WINDOWS\\system32\\python25.zip']
Server time: Sat, 6 Mar 2010 01:18:27 +0000

SettingsPage source

class SettingsPage(webapp.RequestHandler):
    def get(self):
        if users.get_current_user():
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
            account_query = OLAccount.all().filter('owner =',users.get_current_user())
            if account_query.count() < 1:
                thisuser = OLAccount(owner = users.get_current_user())
                thisuser.put()
            else:
                thisuser = account_query.fetch(1)[0]

            tracks = [db.get(key) for key in thisuser.track_keys] 
            template_values = {
                'url': url,
                'url_linktext': url_linktext,
                'thisuser': thisuser,
                'tracks': tracks
                }

            path = os.path.join(os.path.dirname(__file__), 'html/settings.html')
            self.response.out.write(template.render(path, template_values))
        else:
            self.redirect(users.create_login_url(self.request.uri))
A: 

Please provide some code.

Is default __ new __ your own method?

..fredrik

fredrik
+1  A: 

You appear to have subclassed (at least once) a Django's view class with an __init__ (but not a __new__) with a non-standard signature. If you click on the triangle towards the beginning of this message (in your own environment -- the click doesn't work on this copy/pasted msg in SO, of course;-) you should see the local variables, including for example the callback which is the view you're trying to call (comes from your URL resolver, see the source at line 68) -- this information will help further debugging.

Edit: looks like the problem is that you're mixing and matching Django's urlresolvers (which expect Django-id callables, taking the request as the argument) with a subclass of Google's webapp.RequestHandler (which doesn't take arguments in __init__): don't do that. Use app.yaml to pick what .py script handles requests to each group of paths in your app, and in each .py script use only Django or only webapp -- no mixing.

BTW, the Django that comes with the app engine SDK is 0.96, like the default one on google's servers; but on google's servers you can easily switch to more modern versions of django with use_library, while on your SDK you can't -- that is, not without installing your own django locally &c. See the page I just pointed you to and links therefrom.

Alex Martelli
Added the traceback and the settingspage source, which seems implicated. Appreciate your time looking at this, I'm assuming it's a newbie's mistake of some sort, this is my first time trying to set up a django/GAE project.
Jeremy
Ah yes, looks like I mixed and matched solutions from two different places. Still figuring out the differences between using django templates and webapp templates. Thanks very much! Truly appreciate the push in the right direction.
Jeremy
@Jeremy, thanks are nice, accepting answers is better (use the checkmark-shaped icon next to the number of upvotes for the answer you want to accept, e.g. the big 0 in this case;-). Accepting an answer also gives you 2 points of reputation, edging you up towards the magic threshold of 15 where you can also "upvote" answers (both to your own questions, and others) -- read about the fundamental mechanics of StackOverflow at http://stackoverflow.com/faq .
Alex Martelli