473,395 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

TypeError: 'int' object is not callable

I'm trying to test a few different approaches to displaying pages via
Cherrypy and I'm not having much luck. Here is my code so far:

import sys, cherrypy, html

class Root:
@cherrypy.expose
def index(self, pageid = None):
selection = html.Page()
return selection.input()
cherrypy.config.update({'server.socket_port': 2572, 'log.screen':
False})
cherrypy.quickstart(Root())

and here is the html.py file that I import:

class Page:
def input(self,dex=None):
if dex == None:
return 404(dex)
else:
return "Something else?"

def err404(self,whatitis="N/A"):
return """<body bgcolor="#666666">
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /
><br /><br /><br /><br />
<center>Sorry the page: """ + str(whatitis) + """ does not exist.<br /
>
<img src="/files/images/404.png" alt="Page cannot be found."></center>
</body>"""

and here is the error I get when trying to run this:

500 Internal Server Error
The server encountered an unexpected condition which prevented it from
fulfilling the request.

Traceback (most recent call last):
File "/home2/awasilenko/lib/python2.4/cherrypy/_cprequest.py", line
342, in respond
cherrypy.response.body = self.handler()
File "/home2/awasilenko/lib/python2.4/cherrypy/_cpdispatch.py", line
15, in __call__
return self.callable(*self.args, **self.kwargs)
File "/home2/awasilenko/webapps/cp/site.py", line 7, in index
return selection.input()
File "/home2/awasilenko/webapps/cp/html.py", line 4, in input
return 404(dex)
TypeError: 'int' object is not callable

I know this isn't a Cherrypy issue since I have made other pages work,
I'm just making a dumb mistake somewhere. My plan is to eventually be
able to pass dex to the input def in the page class so it can display
the right page. Right now I am just trying to make ANY thing show up,
what should happen is since I'm not passing anything everything should
be None and the 404 page should pop up. I would also like to make the
404 page print the page that was requested, I have already coded the
return but have not "connected" it yet, one step at a time...

Mar 23 '07 #1
2 6693
On Mar 22, 6:54 pm, AWasile...@gmail.com wrote:
I'm trying to test a few different approaches to displaying pages via
Cherrypy and I'm not having much luck. Here is my code so far:

import sys, cherrypy, html

class Root:
@cherrypy.expose
def index(self, pageid = None):
selection = html.Page()
return selection.input()

cherrypy.config.update({'server.socket_port': 2572, 'log.screen':
False})
cherrypy.quickstart(Root())

and here is the html.py file that I import:

class Page:
def input(self,dex=None):
if dex == None:
return 404(dex)
else:
return "Something else?"

def err404(self,whatitis="N/A"):
return """<body bgcolor="#666666">
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />

<center>Sorry the page: """ + str(whatitis) + """ does not exist.<br /

<img src="/files/images/404.png" alt="Page cannot be found."></center>
</body>"""

and here is the error I get when trying to run this:

500 Internal Server Error
The server encountered an unexpected condition which prevented it from
fulfilling the request.

Traceback (most recent call last):
File "/home2/awasilenko/lib/python2.4/cherrypy/_cprequest.py", line
342, in respond
cherrypy.response.body = self.handler()
File "/home2/awasilenko/lib/python2.4/cherrypy/_cpdispatch.py", line
15, in __call__
return self.callable(*self.args, **self.kwargs)
File "/home2/awasilenko/webapps/cp/site.py", line 7, in index
return selection.input()
File "/home2/awasilenko/webapps/cp/html.py", line 4, in input
return 404(dex)
TypeError: 'int' object is not callable

I know this isn't a Cherrypy issue since I have made other pages work,
I'm just making a dumb mistake somewhere. My plan is to eventually be
able to pass dex to the input def in the page class so it can display
the right page. Right now I am just trying to make ANY thing show up,
what should happen is since I'm not passing anything everything should
be None and the 404 page should pop up. I would also like to make the
404 page print the page that was requested, I have already coded the
return but have not "connected" it yet, one step at a time...
404 is an integer literal; you can't use it as a function name.

Mar 23 '07 #2
On Mar 22, 8:59 pm, "Dan Bishop" <danb...@yahoo.comwrote:
On Mar 22, 6:54 pm, AWasile...@gmail.com wrote:


I'm trying to test a few different approaches to displaying pages via
Cherrypy and I'm not having much luck. Here is my code so far:
import sys, cherrypy, html
class Root:
@cherrypy.expose
def index(self, pageid = None):
selection = html.Page()
return selection.input()
cherrypy.config.update({'server.socket_port': 2572, 'log.screen':
False})
cherrypy.quickstart(Root())
and here is the html.py file that I import:
class Page:
def input(self,dex=None):
if dex == None:
return 404(dex)
else:
return "Something else?"
def err404(self,whatitis="N/A"):
return """<body bgcolor="#666666">
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<center>Sorry the page: """ + str(whatitis) + """ does not exist.<br /
<img src="/files/images/404.png" alt="Page cannot be found."></center>
</body>"""
and here is the error I get when trying to run this:
500 Internal Server Error
The server encountered an unexpected condition which prevented it from
fulfilling the request.
Traceback (most recent call last):
File "/home2/awasilenko/lib/python2.4/cherrypy/_cprequest.py", line
342, in respond
cherrypy.response.body = self.handler()
File "/home2/awasilenko/lib/python2.4/cherrypy/_cpdispatch.py", line
15, in __call__
return self.callable(*self.args, **self.kwargs)
File "/home2/awasilenko/webapps/cp/site.py", line 7, in index
return selection.input()
File "/home2/awasilenko/webapps/cp/html.py", line 4, in input
return 404(dex)
TypeError: 'int' object is not callable
I know this isn't a Cherrypy issue since I have made other pages work,
I'm just making a dumb mistake somewhere. My plan is to eventually be
able to pass dex to the input def in the page class so it can display
the right page. Right now I am just trying to make ANY thing show up,
what should happen is since I'm not passing anything everything should
be None and the 404 page should pop up. I would also like to make the
404 page print the page that was requested, I have already coded the
return but have not "connected" it yet, one step at a time...

404 is an integer literal; you can't use it as a function name.- Hide quoted text -

- Show quoted text -
I saw that 404 was turning colors in my editor when I used it, that's
why I changed the def name, I just forgot to change it in the input
def also. Here is the working code now:

class Page:
def input(self,dex=None):
if dex == None:
return self.err404(dex)
else:
return "Something else?"

def err404(self,whatitis="N/A"):
return """<body bgcolor="#666666">
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /
><br /><br />
<center>Sorry the page: """ + str(whatitis) + """ does not exist.<br /
>
<img src="/files/images/404.png" alt="Page cannot be found."></center>
</body>"""

Now I can work on getting the other stuff working. I can't believe
something that stupid was holding me up, oh well :)

Mar 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Atul Kshirsagar | last post by:
Hello, I am using Python 2.3.2 with a C++ extention DLL in muti-threaded environment. 1. For each new thread I create a separate sub-interpreter. 2. Each thread executes multiple python...
7
by: ‘5ÛHH575-UAZWKVVP-7H2H48V3 | last post by:
(see end of message for example code) When an instance has a dynamically assigned instance method, deepcopy throws a TypeError with the message "TypeError: instancemethod expected at least 2...
5
by: Randall Parker | last post by:
Using Python 2.4.2 on Windows 2000 in SPE. Getting: TypeError: 'str' object is not callable on this line: TmpErrMsg1 = "State machine %s " (StateMachineName) In Winpdb 1.0.6 the...
1
by: Gary Wessle | last post by:
dear python users I am not sure why I am getting **************************************************************** Traceback (most recent call last): File "my.py", line 3, in ?...
10
by: Charles Russell | last post by:
Why does this work from the python prompt, but fail from a script? How does one make it work from a script? #! /usr/bin/python import glob # following line works from python prompt; why not in...
33
by: christophertidy | last post by:
Hi I am new to Python and have recieved this error message when trying to instantiate an object from a class from another file within the same directory and wondered what I have done wrong. I...
1
by: Traclo | last post by:
I am doing a computer science project and I have to take a string that contains numbers, double each number individually and then return the doubled integers as one large string. I tried this...
1
by: Charles Fox | last post by:
Hi gys -- I am looking at Numpy but getting this error when I try to get array sizes. I'm using Ubuntu Edgy with standard repositories and scipy. Any ideas? Am I doing something wrong or is it...
10
by: est | last post by:
>>import md5 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python25\lib\pickle.py", line 1366, in dumps Pickler(file, protocol).dump(obj) File...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.