[Zope] attribute-less object(assign or del)

Kate Legere klegere at kfpl.ca
Mon Dec 11 09:31:03 EST 2006


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) 	klegere at kfpl.ca (klegere at kfpl.ca)
Request URL
http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display/copy_of_stats_ou
tput_branch
Exception Type 	TypeError
Exception Value 	attribute-less object (assign or del)

Traceback (innermost last):

    * Module ZPublisher.Publish, line 115, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 41, in call_object
    * Module Shared.DC.Scripts.Bindings, line 311, in __call__
    * Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
    * Module Products.PythonScripts.PythonScript, line 323, in _exec
    * Module None, line 45, in copy_of_stats_output_branch
      <PythonScript at
/kfplStaff/statsTracker/display/copy_of_stats_output_branch>
      Line 45
    * Module RestrictedPython.Guards, line 96, in handler

TypeError: attribute-less object (assign or del)


REQUEST
form
startDate	'2006-11-01'
endDate	'2006-11-03'
self	'copy_of_stats_output_branch'
month	'November'
branch	'Central Library'
year	'2006'
cookies
__utmz
'69369802.1165693521.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)'
tree-s
'eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuRKCECUjWFEnWpSwZJGsGljUHyVogySaZWIBkLcGyhgY
gaUNDhLyHqS9Yt6ERVyIU6AEAY0whEw'
__utma	'69369802.1218542946.1165693521.1165699185.1165846618.3'
__utmb	'69369802'
__utmc	'69369802'
_ZopeId	'78463451A2odH2u-mbs'
lazy items
SESSION	<bound method SessionDataManager.getSessionData of
<SessionDataManager at /session_data_manager>>
other
startDate	'2006-11-01'
endDate	'2006-11-03'
TraversalRequestNameStack	[]
AUTHENTICATED_USER	<LDAPUser 'klegere at kfpl.ca'>
URL
'http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display/copy_of_stats_o
utput_branch'
year	'2006'
SERVER_URL	'http://staffnet.kfpl.ca:8080'
AUTHENTICATION_PATH	'kfplStaff'
traverse_subpath	[]
USER_PREF_LANGUAGES	<itools.i18n.accept.AcceptLanguage instance at
0xc2a1c6c>
branch	'Central Library'
PUBLISHED	<PythonScript at
/kfplStaff/statsTracker/display/copy_of_stats_output_branch>
AcceptLanguage	<itools.i18n.accept.AcceptLanguage instance at 0xc2a1c6c>
AcceptCharset	<itools.i18n.accept.AcceptCharset instance at 0xac4740cc>
month	'November'
ACTUAL_URL
'http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display/copy_of_stats_o
utput_branch'
URL0
http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display/copy_of_stats_ou
tput_branch
URL1	http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display
URL2	http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker
URL3	http://staffnet.kfpl.ca:8080/kfplStaff
URL4	http://staffnet.kfpl.ca:8080
BASE0	http://staffnet.kfpl.ca:8080
BASE1	http://staffnet.kfpl.ca:8080
BASE2	http://staffnet.kfpl.ca:8080/kfplStaff
BASE3	http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker
BASE4	http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display
BASE5
http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display/copy_of_stats_ou
tput_branch
environ
HTTP_COOKIE
'__utma=69369802.1218542946.1165693521.1165699185.1165846618.3;
__utmb=69369802; __utmc=69369802;
__utmz=69369802.1165693521.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
;
tree-s="eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuRKCECUjWFEnWpSwZJGsGljUHyVogySaZWIBk
LcGyhgYgaUNDhLyHqS9Yt6ERVyIU6AEAY0whEw"; _ZopeId="78463451A2odH2u-mbs"'
SERVER_SOFTWARE	'Zope/(Zope 2.9.2-, python 2.4.3, linux2) ZServer/1.1'
SCRIPT_NAME	''
REQUEST_METHOD	'GET'
HTTP_KEEP_ALIVE	'300'
SERVER_PROTOCOL	'HTTP/1.1'
QUERY_STRING
'self=copy_of_stats_output_branch&startDate=2006-11-01&endDate=2006-11-03&mo
nth=November&year=2006&branch=Central%20Library'
channel.creation_time	1165847076
CONNECTION_TYPE	'keep-alive'
HTTP_ACCEPT_CHARSET	'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_USER_AGENT	'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8)
Gecko/20061025 Firefox/1.5.0.8'
HTTP_REFERER
'http://staffnet.kfpl.ca:8080/kfplStaff/statsTracker/display/copy_of_stats_o
utput_branch/ZScriptHTML_tryForm'
SERVER_NAME	'0.0.0.0'
REMOTE_ADDR	'192.168.10.229'
PATH_TRANSLATED
'/kfplStaff/statsTracker/display/copy_of_stats_output_branch'
SERVER_PORT	'8080'
HTTP_HOST	'staffnet.kfpl.ca:8080'
HTTP_ACCEPT
'application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xm
l,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'
GATEWAY_INTERFACE	'CGI/1.1'
HTTP_ACCEPT_LANGUAGE	'en-us,en;q=0.5'
HTTP_ACCEPT_ENCODING	'gzip,deflate'
PATH_INFO
'/kfplStaff/statsTracker/display/copy_of_stats_output_branch'



This is the code that produced it: 

request = container.REQUEST
RESPONSE =  request.RESPONSE
origBranch = ' '
origCategory = ' '
origDate = ' '
category= 'Adult'

table_example="""
     <table border="1" width="700">
        <tr> 
             <td colspan="15" align="center"> <h3>Reference
Statistics</h3></td>
        </tr>

        <tr>
              <td colspan="2">&nbsp;</td>
              <td >9 am</td>
              <td>10 am</td>
              <td>11 am</td>
              <td>12 pm</td>
              <td>1 pm</td>
              <td>2 pm</td>
              <td>3 pm</td>
              <td>4 pm</td>
              <td>5 pm</td>
              <td>6 pm</td>
              <td>7 pm</td>
              <td>8 pm</td>
              <td>Total</td>
         </tr>""" 

for i in self.sql.sqlGetDatesWithBranchAndCat(startDate1=startDate,
endDate1=endDate, branch=branch, category=category):

     table_example=table_example+"""
          <tr>
              <td colspan="15"><b></b></td></tr><tr><td
colspan="2">&nbsp;</td>"""

     for k in range(9,21):

         table_example=table_example+"""<td>"""  
             

         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)+'&nbsp;'   
              else:
                 table_example=table_example+'&nbsp;'

         table_example=table_example+'</td>'

     table_example=table_example+'</tr>'
#  ends next row

table_example=table_example+'</table>'


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:dieter at handshake.de] 
Sent: Sunday, December 10, 2006 12:50 PM
To: Kate Legere
Cc: zope at 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
><PythonScript at 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



More information about the Zope mailing list