All, I am trying to work an example that I found at http://bitworking.org/news/132/REST-Tips-URI-space-is-infinite When I try the code below I get an error and I am not able to figure it out. Thanks for any and all help. I have two png and a text file (sortzip.txt) in the same dir as this code but I do not even get to that part...the mmap call is bad. I have never used mmap before so this is new to me. I am running python 2.4 John ############# code from mmap import mmap import os from bisect import bisect_left import sys class Zipcodes(object): """Use mmap to treat the sorted file of zipcodes as an array""" def __init__(self): self.f = open("sortzips.txt", "r+") self.size = os.path.getsize("sortzips.txt") self.m = mmap(self.f.fileno(), self.size) def __getitem__(self, i): self.m.seek(6*i) return self.m.read(5) def __del__(self): self.m.close() self.f.close() def __len__(self): return self.size / 6 zipcodes = Zipcodes() target = os.environ.get('PATH_INFO', '/')[1:] found = ( zipcodes[bisect_left(zipcodes, target)] == target ) print "Status: " + ( found and "200 Ok" or "404 Not Found" ) print "Cache-control: max-age=172800" print "Content-type: image/png" print "" file = open(found and "good.png" or "bad.png", "r") png = file.read() file.close() sys.stdout.write(png) ########################## error message when I try to run this. Traceback (most recent call last): File "./zipcode.cgi", line 23, in ? zipcodes = Zipcodes() File "./zipcode.cgi", line 14, in __init__ self.m = mmap(self.f.fileno(), self.size) EnvironmentError: [Errno 22] Invalid argument Exception exceptions.AttributeError: "'Zipcodes' object has no attribute 'm'" in <bound method Zipcodes.__del__ of <__main__.Zipcodes object at 0xbdf080cc>> ignored
########################### John Ertl Meteorologist FNMOC 7 Grace Hopper Ave. Monterey, CA 93943 (831) 656-5704 [EMAIL PROTECTED]
<<winmail.dat>>
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor