WebFaction
Community site: login faq

I can't seem to figure out what part of my setup is breaking. Hopefully someone here can point me in the right direction.

my file structure:

--myapp
    --apache2
    --htdocs
        --index.py
        --myapplication
            --app.py
            --__init__.py

my index.py:

import sys 
sys.path.append('/home/name/webapps/app/htdocs/')
sys.path.append('/home/name/webapps/app/htdocs')
sys.path.append('/home/name/webapps/app/htdocs/application')
sys.path.append('/home/name/webapps/app/htdocs/application/')

from application import app as application

my http.conf:

ServerRoot "/home/name/webapps/app/apache2"

LoadModule dir_module        modules/mod_dir.so
LoadModule env_module        modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module       modules/mod_mime.so
LoadModule rewrite_module    modules/mod_rewrite.so
LoadModule setenvif_module   modules/mod_setenvif.so
LoadModule wsgi_module       modules/mod_wsgi.so

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/name/logs/user/access_app.log combined
DirectoryIndex index.py
DocumentRoot /home/name/webapps/app/htdocs
ErrorLog /home/name/logs/user/error_app.log
KeepAlive Off
Listen 33987
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess follow_hackers processes=5 python-path=/home/name/webapps/app:/home/name/webapps/app/lib/python2.7:/home/name/webapps/app/htdocs threads=1
WSGIProcessGroup app
WSGIRestrictEmbedded On
WSGILazyInitialization On

WSGIRestrictSignal Off

<Directory /home/name/webapps/app/htdocs>
    AddHandler wsgi-script .py
</Directory>

WSGIPythonPath /home/name/webapps/app/htdocs/
#If you do not specify the following directive the app *will* work but you will
#see index.py in the path of all URLs
WSGIScriptAlias / /home/name/webapps/app/htdocs/index.py

<Directory /home/name/webapps/app/htdocs/>
   AddHandler wsgi-script .py
   RewriteEngine on
   RewriteBase /
   WSGIScriptReloading On
</Directory>

and when I run apache and load the page I get a 500 error with the log:

[Thu Jul 19 19:29:41 2012] [error] [client 127.0.0.1] mod_wsgi (pid=23944): Exception occurred processing WSGI script '/home/danieln/webapps/follow_hackers/htdocs/index.py'.
[Thu Jul 19 19:29:41 2012] [error] [client 127.0.0.1] TypeError: 'module' object is not callable

can someone please tell me why this isn't working

asked 19 Jul '12, 19:37

DanielN
323
accept rate: 0%

Per the support ticket you opened, I believe this error is related to one of the Python modules you're using. I'll leave the answer open for anyone who has a better idea.

(20 Jul '12, 13:14) seanf

I may have been having a similar problem. Just don't use "application" folder. Put every file in /htdocs

For some reason subdirectories cause issues.

So your "app" stuff, app.route etc., should be in htdocs.

You can use blueprints for the rest and have those in subfolders, but the main site should be in /htdocs, as YourApp.py (alongside index.py)

permanent link

answered 20 Nov '12, 21:07

execute
726
accept rate: 0%

In Python, everything (including functions, methods, modules, classes etc.) is an object , and methods are just attributes like every others. So,there's no separate namespaces for methods. So when you set an instance attribute, it shadows the class attribute by the same name. The obvious solution is to give attributes different names .

This error statement TypeError: 'module' object is not callable is raised as you are being confused about the Class name and Module name. The problem is in the import line . You are importing a module, not a class. This happend because the module name and class name have the same name .

If you have a class "MyClass" in a file called "MyClass.py" , then you should import :

from MyClass import MyClass

In Python , a script is a module, whose name is determined by the filename . So when you start out your file MyClass.py with import MyClass you are creating a loop in the module structure.

permanent link

answered 04 Feb, 06:34

cronywalls
212
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×55
×44
×29

question asked: 19 Jul '12, 19:37

question was seen: 5,186 times

last updated: 04 Feb, 06:34

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM