Skip to content
alabid edited this page Aug 10, 2012 · 16 revisions

Frequently Asked Questions (and TroubleShooting)

Q: Once I start the server using python main.py, I see the error socket.error: [Errno 98] Address already in use. What am I doing wrong?

A: This error shows up when you attempt to start a server on a port that's already in use by another application. By default, the whirlwind application runs on port 8000. So you'd have to run your new server on another port. To do so, edit the file config/settings.py. Set the port variable to an open port (that's not in use). For example,

# define a port for testing
port = 8001 # changed port from 8000 to 8001 that's currently not being used

If you are still having problems knowing which ports are in use and which aren't, you can use the netstat -a linux/unix utility to see the listening and non-listening ports on your machine.


Q: How can I make my editor recognize the syntax of my custom mako templates?

A: Try putting # -*- coding: utf-8 -*- on the first line of your mako templates. This is a way of specifying the encoding of a Python file. It comes from PEP 0263 - Defining Python Source Code Encodings.

It is also recognized by GNU Emacs (see Python Language Reference, 2.1.4 Encoding declarations) and many other text editors.


Q : I keep getting the error ConnectionError: No collection found whenever I try to save an instance of a model via the save method. What am I doing wrong?

A : This error occurs whenever you try to access a collection that doesn't exist. So you're probably experiencing an error on attempting to save the first instance of some model you created. Instead of using the save method, just use insert on the database to directly insert the instance of the model into the database collection.

So instead of:

user = User()
user.save()

do:

user = User()
self.db.users.User.insert(user)
# if you are in a controller

# ----------------------------------------------------------------
user = User()
Mongo.db.ui.users.User.insert(user)
# if you are in either a controller or in a model definition file

Q : I always see the error AutoReconnect: could not connect to localhost:27017: [Errno 111] or some other error statement about errors in connecting to the database. How can I fix it?

A : You are probably getting this error because the mongo daemon isn't running. You can start the mongo daemon via the command mongod --dbpath <my-db-path>.


Q : I tried to start up the mongo daemon but it just doesn't start up. What am I doing wrong?

A : It might just be that the mongo daemon is already running. You can check if the daemon is already running by ps -A | grep mongod. This searches all the processes that are currently being run by the current user. It prints out mongod and the PID of mongod if it's already running.

If it's already running, you can just use the database. Or else, consult the mongodb docs or stackoverflow to solve the problem.


Q : I can't get my flash messages to work. How can I solve the problems with flash messages?

A : To trouble shoot flash messages, first make sure you have gone through the exposition on whirlwind flash messages.

Here are some ways you can try to solve problems you might have with flash messages:

  • First, check your console to see if you get any JavaScript errors. If you do, then it probably has to do with the flash-messages.js file that defines a method to display flash messages. If the console error complains about the use of $ which corresponds to the jQuery object, then make sure that you load jQuery before you load flash-messages.js.

  • If you don't get any Javascript errors but the flash messages just don't appear, then check that your server console doesn't error. If there are errors in the server console, it might be because you disabled sessions which have to be enabled for flash messaging to work.

  • If on loading the page on which flash messages should appear, you don't see any content in the browser, then it might be because you didn't redirect the request to a new page. After storing flash messages in the self.flash object, you must redirect the request to the page you wish to display the flash messages in.

  • If you see a different page other than the content of the page you think you redirected the user to, it might be because you didn't return from the handler after storing flash messages and redirecting the user to the page you wish to render the flash messages in.

For more information on this, check out the flash messages page.