472,782 Members | 1,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 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 6608
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.