Opened 17 years ago
Closed 17 years ago
#7816 closed defect (duplicate)
UnboundLocalError: local variable 'data' referenced before assignment
| Reported by: | Owned by: | anonymous | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | general | Version: | 0.12dev | 
| Severity: | normal | Keywords: | genshi | 
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
어떻게 재현할 것인가?
While doing a POST operation on /attachment/wiki/WikiStart/SNIPER-20080818_jey035.doc, Trac에서 내부적인 에러가 발생했습니다.
(여기에 추가적인 상세한 정보를 적어주십시오.)
요청 파라메터:
{'__FORM_TOKEN': u'af69e20cabd23fee1ee71a2f',
 'action': [u'delete', u'delete'],
 'path': u'WikiStart/SNIPER-20080818_jey035.doc',
 'realm': u'wiki'}
시스템 정보
| Trac |  0.12dev 
 | 
| Python |  2.6 (r26:66714, Oct 20 2008, 13:55:25)  [GCC 4.1.0 20060304 (Red Hat 4.1.0-3)] 
 | 
| setuptools |  0.6c9 
 | 
| SQLite |  3.3.7 
 | 
| pysqlite |  2.4.1 
 | 
| Genshi |  0.6dev-r960 
 | 
| mod_python |  3.3.1 
 | 
| Pygments |  0.11.1 
 | 
| jQuery: |  1.2.6 
 | 
Python Traceback
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/site-packages/Trac-0.12dev-py2.6.egg/trac/web/main.py", line 456, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.6/site-packages/Trac-0.12dev-py2.6.egg/trac/web/main.py", line 213, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.6/site-packages/Trac-0.12dev-py2.6.egg/trac/attachment.py", line 404, in process_request
    return 'attachment.html', data, None
UnboundLocalError: local variable 'data' referenced before assignment
Attachments (0)
Change History (14)
comment:1 by , 17 years ago
| Keywords: | genshi added | 
|---|---|
| Milestone: | → 0.12 | 
comment:3 by , 17 years ago
this is delete confirmation page source.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  
  
  
  
  <head>
    <title>
      첨부파일 – sniper
    </title>
        <link rel="search" href="/trac/sniper/search" />
        <link rel="help" href="/trac/sniper/wiki/TracGuide" />
        <link rel="up" href="/trac/sniper/wiki/WikiStart" title="WikiStart" />
        <link rel="start" href="/trac/sniper/wiki" />
        <link rel="stylesheet" href="/trac/sniper/chrome/common/css/trac.css" type="text/css" /><link rel="stylesheet" href="/trac/sniper/chrome/common/css/code.css" type="text/css" /><link rel="stylesheet" href="/trac/sniper/chrome/tracwysiwyg/wysiwyg.css" type="text/css" />
        <link rel="shortcut icon" href="/trac/sniper/chrome/common/trac.ico" type="image/x-icon" />
        <link rel="icon" href="/trac/sniper/chrome/common/trac.ico" type="image/x-icon" />
      <link type="application/opensearchdescription+xml" rel="search" href="/trac/sniper/search/opensearch" title="Search sniper" />
    <script type="text/javascript" src="/trac/sniper/chrome/common/js/jquery.js"></script><script type="text/javascript" src="/trac/sniper/chrome/common/js/trac.js"></script><script type="text/javascript" src="/trac/sniper/chrome/common/js/search.js"></script><script type="text/javascript" src="/trac/sniper/chrome/tracwysiwyg/wysiwyg.js"></script><script type="text/javascript" src="/trac/sniper/chrome/tracwysiwyg/wysiwyg-load.js"></script>
    <!--[if lt IE 7]>
    <script type="text/javascript" src="/trac/sniper/chrome/common/js/ie_pre7_hacks.js"></script>
    <![endif]-->
  </head>
  <body>
    <div id="banner">
      <div id="header">
        <a id="logo" href="/"><img src="/images/issue_logo01.gif" alt="(please configure the [header_logo] section in trac.ini)" /></a>
      </div>
      <form id="search" action="/trac/sniper/search" method="get">
        <div>
          <label for="proj-search">검색:</label>
          <input type="text" id="proj-search" name="q" size="18" value="" />
          <input type="submit" value="검색" />
        </div>
      </form>
      <div id="metanav" class="nav">
    <ul>
      <li class="first">hyjung로 로그인됨</li><li><a href="/trac/sniper/logout">로그아웃</a></li><li><a href="/trac/sniper/prefs">설정</a></li><li><a href="/trac/sniper/wiki/TracGuide">도움말</a></li><li class="last"><a href="/trac/sniper/about">Trac에 대해서</a></li>
    </ul>
  </div>
    </div>
    <div id="mainnav" class="nav">
    <ul>
      <li class="first active"><a href="/trac/sniper/wiki">위키</a></li><li><a href="/trac/sniper/timeline">시간이력</a></li><li><a href="/trac/sniper/roadmap">로드맵</a></li><li><a href="/trac/sniper/report">티켓 보기</a></li><li><a href="/trac/sniper/newticket">새로운 티켓</a></li><li><a href="/trac/sniper/search">검색</a></li><li class="last"><a href="/trac/sniper/admin" title="관리">관리</a></li>
    </ul>
  </div>
    <div id="main">
      <div id="ctxtnav" class="nav">
        <h2>컨텍스트 네비게이션</h2>
          <ul>
            <li class="first last"><a href="/trac/sniper/wiki/WikiStart">WikiStart로 돌아가기</a></li>
          </ul>
        <hr />
      </div>
    <div id="content" class="attachment">
        <h1><a href="/trac/sniper/wiki/WikiStart">WikiStart</a>: SNIPER-20080818_jey035.doc</h1>
        <p><strong>이 첨부파일을 정말로 삭제하시겠습니까?</strong><br />
          이 작업은 되돌릴 수 없는 작업입니다.</p>
        <div class="buttons">
          <form method="post" action=""><div><input type="hidden" name="__FORM_TOKEN" value="465130468323fe5ac6bad49a" /></div>
            <div id="delete">
              <input type="hidden" name="action" value="delete" />
              <input type="submit" name="cancel" value="취소" />
              <input type="submit" value="첨부파일 삭제" />
            </div>
          </form>
        </div>
    </div>
    </div>
    <div id="footer" lang="en" xml:lang="en"><hr />
      <a id="tracpowered" href="http://trac.edgewall.org/"><img src="/trac/sniper/chrome/common/trac_logo_mini.png" height="30" width="107" alt="Trac Powered" /></a>
      <p class="left">
        Powered by <a href="/trac/sniper/about"><strong>Trac 0.12dev</strong></a><br />
        By <a href="http://www.edgewall.org/">Edgewall Software</a>.
      </p>
      <p class="right">Visit the Trac open source project at<br /><a href="http://trac.edgewall.org/">http://trac.edgewall.org/</a></p>
    </div>
  </body>
</html>
comment:4 by , 17 years ago
Thanks, there's nothing wrong on the .html level, apparently.
What web browser did you use? Is the problem reproducible (i.e. does it happen always, for every attachment)? Does the problem happen with different browser?
What revision of 0.12dev are you using? Does an upgrade to the latest trunk solve the problem?
comment:5 by , 17 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
I solved it by modify "attachment.py" source file. but it will be not collect solution. As cboos mentioned, the problem was duplicated agument.
below is part of my modified source. it's simple.
    358     def process_request(self, req):
    359         parent_id = None
    360         parent_realm = req.args.get('realm')
    361         path = req.args.get('path')
    362         filename = None
    363
    364         if not parent_realm or not path:
    365             raise HTTPBadRequest(_('Bad request'))
    366
    367         parent_realm = Resource(parent_realm)
    368         action = req.args.get('action', 'view')
    369         if (action == 'new') or (action[0] == 'new') :
    370             parent_id = path.rstrip('/')
    371         else:
    372             segments = path.split('/')
    373             parent_id = '/'.join(segments[:-1])
    374             filename = len(segments) > 1 and segments[-1]
    375
    376         parent = parent_realm(id=parent_id)
    377
    378         # Link the attachment page to parent resource
    379         parent_name = get_resource_name(self.env, parent)
    380         parent_url = get_resource_url(self.env, parent, req.href)
    381         add_link(req, 'up', parent_url, parent_name)
    382         add_ctxtnav(req, _('Back to %(parent)s', parent=parent_name),
    383                     parent_url)
    384
    385         if (action != 'new') and (action[0] != 'new')  and not filename:
    386             # there's a trailing '/', show the list
    387             return self._render_list(req, parent)
    388
    389         attachment = Attachment(self.env, parent.child('attachment', filename))
    390
    391         if req.method == 'POST':
    392             if (action == 'new') or (action[0] == 'new'):
    393                 self._do_save(req, attachment)
    394             elif (action == 'delete') or (action[0] == 'delete'):
    395                 self._do_delete(req, attachment)
    396         elif (action == 'delete') or (action[0] == 'delete'):
    397             data = self._render_confirm_delete(req, attachment)
    398         elif (action == 'new') or (action[0] == 'new') :
    399             data = self._render_form(req, attachment)
    400         else:
    401             data = self._render_view(req, attachment)
    402         add_stylesheet(req, 'common/css/code.css')
    403
    404         return 'attachment.html', data, None
    405
    406     # IWikiSyntaxProvider methods
follow-up: 7 comment:6 by , 17 years ago
Well no, the fix is not to cope with multiple values for this parameter - there shouldn't be multiple values, and we should understand why there are in your situation. Please answer my questions from comment:4.
comment:7 by , 17 years ago
Thanks, there's nothing wrong on the .html level, apparently.
What web browser did you use? Is the problem reproducible (i.e. does it happen >>always, for every attachment)? Does the problem happen with different browser?
What revision of 0.12dev are you using? Does an upgrade to the latest trunk solve the problem?
Replying to cboos:
Well no, the fix is not to cope with multiple values for this parameter - there shouldn't be multiple values, and we should understand why there are in your situation. Please answer my questions from comment:4.
I'm sorry about change mode. I tested by IE7, and Google Chrome. but all of them showed same error. And I was captured packet by ethereal. I think that this error is not sending source. It may will be receiveing script error. just like not buffer clear. Just my think.
comment:8 by , 17 years ago
| Resolution: | fixed | 
|---|---|
| Status: | closed → reopened | 
comment:9 by , 17 years ago
| Resolution: | → duplicate | 
|---|---|
| Status: | reopened → closed | 
This is due to a change in the cgi module in Python 2.6, and hence a duplicate of #7876.
comment:10 by , 17 years ago
| Milestone: | 0.12 | 
|---|
comment:11 by , 17 years ago
| Owner: | set to | 
|---|
comment:12 by , 17 years ago
| Resolution: | duplicate | 
|---|---|
| Status: | closed → reopened | 
comment:13 by , 17 years ago
| Status: | reopened → new | 
|---|



  
'action': [u'delete', u'delete'],is the problem, should be'action': u'delete'.The request argument got duplicated somehow, can you post the html source of your attachment delete confirmation page?
Also, do you use any custom site.html template, containing py:matches? If so, post it here as well (suspecting something like #G254).