RE: [Zope] attribute-less object(assign or del)
It turned out, actually to be easier than I though to correct this - I ended up trapping the exception whenever one occurred. Thanks for all the input. Katie -Original Message- From: Dieter Maurer [mailto:[EMAIL PROTECTED] Sent: Sunday, December 17, 2006 4:25 AM To: Kate Legere Cc: zope@zope.org Subject: RE: [Zope] attribute-less object(assign or del) Kate Legere wrote at 2006-12-11 09:31 -0500: >This is the full trackback: > > >Site Error Log Site Error Log at /error_log >Exception traceback > >Time 2006/12/11 09:26:04.451 US/Eastern >User Name (User Id)[EMAIL PROTECTED] ([EMAIL PROTECTED]) >Request URL >http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display/copy_of_stats_o u >tput_branch >Exception Type TypeError >Exception Valueattribute-less object (assign or del) > > /kfplStaff/statsTracker/display/copy_of_stats_output_branch> > Line 45 >* Module RestrictedPython.Guards, line 96, in handler > >TypeError: attribute-less object (assign or del) This gives us another two potential problem causes. * It is likely that you cannot change 'Record' attributes in restricted code (such as in 'PythonScript'). Try in trusted code (e.g. an "ExternalMethod"). * Maybe, you try to change not a "Record" instance (a single hit) but the "Result" instance (representing the complete result list). "Result" instances do not have any writable attributes. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] attribute-less object(assign or del)
Kate Legere wrote at 2006-12-11 09:31 -0500: >This is the full trackback: > > >Site Error Log Site Error Log at /error_log >Exception traceback > >Time 2006/12/11 09:26:04.451 US/Eastern >User Name (User Id)[EMAIL PROTECTED] ([EMAIL PROTECTED]) >Request URL >http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display/copy_of_stats_ou >tput_branch >Exception Type TypeError >Exception Valueattribute-less object (assign or del) > > /kfplStaff/statsTracker/display/copy_of_stats_output_branch> > Line 45 >* Module RestrictedPython.Guards, line 96, in handler > >TypeError: attribute-less object (assign or del) This gives us another two potential problem causes. * It is likely that you cannot change 'Record' attributes in restricted code (such as in 'PythonScript'). Try in trusted code (e.g. an "ExternalMethod"). * Maybe, you try to change not a "Record" instance (a single hit) but the "Result" instance (representing the complete result list). "Result" instances do not have any writable attributes. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] attribute-less object(assign or del)
ference Statistics 9 am 10 am 11 am 12 pm 1 pm 2 pm 3 pm 4 pm 5 pm 6 pm 7 pm 8 pm Total """ for i in self.sql.sqlGetDatesWithBranchAndCat(startDate1=startDate, endDate1=endDate, branch=branch, category=category): table_example=table_example+""" """ for k in range(9,21): table_example=table_example+"""""" for j in self.sql.sqlGetStatDetailsSum(date1=i.date, branch1=i.branch, category1=i.category, timeCheck1=k): if str(j.sum_renewals)== 'None': j.sum_renewals = 0 elif str(j.sum_registrations)== 'None': j.sum_registrations = 0 elif str(j.sum_hours)== 'None': j.sum_hours = 0 elif str(j.sum_reference)== 'None': j.sum_reference = 0 total = j.sum_renewals + j.sum_registrations + j.sum_hours + j.sum_reference if str(total) != 'None': table_example=table_example+str(total)+' ' else: table_example=table_example+' ' table_example=table_example+'' table_example=table_example+'' # ends next row table_example=table_example+'' RESPONSE.setHeader("Content-type","application/vnd.ms-excel") RESPONSE.setHeader("Content-disposition","file;filename=statsSpreadsheet.xls ") return table_example - Now, when I run the code on a date range that I know has an entry in every field I'm just fine, it's only when there isn't an entry that I get the error. Katie -Original Message- From: Dieter Maurer [mailto:[EMAIL PROTECTED] Sent: Sunday, December 10, 2006 12:50 PM To: Kate Legere Cc: zope@zope.org Subject: Re: [Zope] attribute-less object(assign or del) Kate Legere wrote at 2006-12-9 13:54 -0500: >Module None, line 45, in copy_of_stats_output_branch > >Line 45 > > >for j in self.sql.sqlGetStatDetailsSum(date1=i.date, branch1=i.branch, >category1=i.category, timeCheck1=k): > > if str(j.sum_renewals)== 'None': > line 45 --> j.sum_renewals = 0 The rows in "ZSQL Method" results are special objects ("Record.Record" instances). They only allow assignment to existing attributes. Trying to assign to a non existing attribut results in an "AttributeError". The problem you report, however, does not seem to come from the code you quote. Please always provide full error information in your problem reports. This includes the full traceback, the error type and error value. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] attribute-less object(assign or del)
Kate Legere wrote: Module None, line 45, in copy_of_stats_output_branch Line 45 for j in self.sql.sqlGetStatDetailsSum(date1=i.date, branch1=i.branch, category1=i.category, timeCheck1=k): if str(j.sum_renewals)== 'None': line 45 --> j.sum_renewals = 0 elif str(j.sum_registrations)== 'None': j.sum_renewals = 0 elif str(j.sum_hours)== 'None': j.sum_renewals = 0 elif str(j.sum_reference)== 'None': j.sum_renewals = 0 When I have values returned by the sql call it works fine but as soon as I get to a field that has a 0 in it then I get an error... As far as I can tell I'm doing the assignment correctly ... what's wrong here? Kate Kate, But the code looks weird ... Id test something like if not j.sum_renewals: j.sum_renewals = 0 David H ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )