* Tim Johnson <t...@johnsons-web.com> [110313 08:27]: > One other thing I just realized: > The process stops inside of a function call to another object > method, if that method call is removed, the process teminates. > :) I may have a solution later today, and will relay it to you if > found. Must have coffee first. I've had coffee, and also I've eaten a bit of crow. If I had no dignity to spare I might have dropped this thread after the last post, but I owe it to those who might come after me to explain what happened. If I have any excuse, it is that I wrote this code when I had about a month of python experience. So here we go... The cleanup part is to write a logfile. The logfile is written by the write() method of a log object. The method was coded to accept any number of data types and execute based on the type from an if/elif/else code block. The cgi object was passed to the method. The original code follows: ## code begins if type(args) == type({}): ## it's a dictionary args['time_date_stamp'] = '%s%d' % (std.local_time(),std.randomize(8)) keys = args.keys() keys.sort() for key in keys: outfile.write('\t%s: %s\n' % (key,args[key])) elif type(args) == type(''): outfile.write('%s\n%s\n' % (std.local_time(),args)) elif std.IsCgiObj(args): ## dump the cgi object dump = args.getEnv('time_date_stamp=%s' % (std.local_time())) for line in dump: outfile.write(' %s\n' % line) else : ## default = it's a list if args: outfile.write('time_date_stamp=%s\n' % (std.local_time())) for arg in args: outfile.write(' %s\n' % arg) ## /code ends I did two obvious things wrong here: First of all, std.IsCgiObj() returned false when I changed the class name because std.IsCgiObj() tested for an explicit match of 'cgitools' with the objects __class__.__name__ member.
Secondly, and worse, the default of the test block was an assumption and I did not test the assumption. Bad, bad, very bad! Therefore my code attempted to process the object as a list and down the Rabit Hole we went. And I ended up with some *really* big logfiles :). Following is a tentative revision: ## code begins elif 'instance' in (str(type(args))): ## it's an object if hasattr(args,'getEnv'): ## test for method dump = args.getEnv('time_date_stamp=%s' % (std.local_time())) for line in dump: outfile.write(' %s\n' % line) else : erh.Report("object passed to logger.write() must have a `getEnv()' method" ) else : ## it's a list if type(args) != []: ## make no assumptions erh.Report('List expected in default condition of logger.write()') if args: outfile.write('time_date_stamp=%s\n' % (std.local_time())) for arg in args: outfile.write(' %s\n' % arg) ## /code ends ## erh.Report() writes a messages and aborts process. Of course, I could have problems with an object with a malfunctioning getEnv() method, so I'll have to chew that one over for a while. I appreciate Terry's help. I'd welcome any other comments. I'm also researching the use of __class__.__name__. One of my questions is: can the implementation of an internal like __class__.__name__ change in the future? -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list