jvasile / Planeteria

Multiple Blog Planet Site

Home Page:http://planeteria.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

<type 'exceptions.AttributeError'> while adding a feed

opened this issue · comments

Feed URL: http://fredjoiner.wordpress.com/feed/atom/

Error

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 /var/www/planeteria2/www/allarounddc/admin.py in ()
    215    a = Admin(template_vars(planet, Form)).render()
    216    sys.stdout.write(a)
    217 
    218 if __name__ == "__main__":
=>  219    main()
main = <function main>
 /var/www/planeteria2/www/allarounddc/admin.py in main()
    196    if Form.has_key('PlanetName'):
    197       orig_pass = planet.password
=>  198       planet = update_config(planet)
    199 
    200       if Form.getvalue('Timestamp') != str(planet.last_config_change):
planet = <planet.Planet instance>, global update_config = <function update_config>
 /var/www/planeteria2/www/allarounddc/admin.py in update_config(planet=<planet.Planet instance>)
    135    urls_seen = []
    136    while (Form.has_key('section%d' % feed_count)):
=>  137       url = Form.getvalue('feedurl%d' % feed_count,'').strip()
    138       urls_seen.append(url)
    139       if not url:
url undefined, global Form = FieldStorage(None, None, [MiniFieldStorage('Time...d3.jpeg'), MiniFieldStorage('Pass', '[censored]')]), Form.getvalue = <bound method FieldStorage.getvalue of FieldStor...3.jpeg'), MiniFieldStorage('Pass', '[censored]')])>, feed_count = 0, ).strip undefined
<type 'exceptions.AttributeError'>: 'list' object has no attribute 'strip' 
      args = ("'list' object has no attribute 'strip'",) 
      message = "'list' object has no attribute 'strip'"
commented

Yep, I also had this but while clicking the "save" button at the bottom of the page.

<type 'exceptions.AttributeError'> Python 2.7.3rc2: /usr/bin/python
Sat Mar 16 03:30:39 2013

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/var/www/planeteria2/www/feministhackers/admin.py in ()
215 a = Admin(template_vars(planet, Form)).render()
216 sys.stdout.write(a)
217
218 if name == "main":
=> 219 main()
main =
/var/www/planeteria2/www/feministhackers/admin.py in main()
196 if Form.has_key('PlanetName'):
197 orig_pass = planet.password
=> 198 planet = update_config(planet)
199
200 if Form.getvalue('Timestamp') != str(planet.last_config_change):
planet = <planet.Planet instance>, global update_config =
/var/www/planeteria2/www/feministhackers/admin.py in update_config(planet=<planet.Planet instance>)
135 urls_seen = []
136 while (Form.has_key('section%d' % feed_count)):
=> 137 url = Form.getvalue('feedurl%d' % feed_count,'').strip()
138 urls_seen.append(url)
139 if not url:
url undefined, global Form = FieldStorage(None, None, [MiniFieldStorage('Time..._blue.jpg'), MiniFieldStorage('Pass', 'passme')]), Form.getvalue = <bound method FieldStorage.getvalue of FieldStor...blue.jpg'), MiniFieldStorage('Pass', 'passme')])>, feed_count = 0, ).strip undefined

<type 'exceptions.AttributeError'>: 'list' object has no attribute 'strip'
args = ("'list' object has no attribute 'strip'",)
message = "'list' object has no attribute 'strip'"

I think I may have found the cause of this and did a quick fix. Pull request submitted - let's hope it works for you!

Closed, thanks to Aleta's 3289266 patch.

Reopening this, requires more testing to make sure it didn't create another issue. Lizzard reported an error on line 162. Tested to see if it's due to her attempting to add the same feed as she added previously when she encountered the error, but it still dies at Line 162 when adding a completely different feed.

I tried again with http://fredjoiner.wordpress.com/feed/atom/
and got

 /var/www/planeteria2/www/allarounddc/admin.py in ()
    227    a = Admin(template_vars(planet, Form)).render()
    228    sys.stdout.write(a)
    229 
    230 if __name__ == "__main__":
=>  231    main()
main = <function main>
 /var/www/planeteria2/www/allarounddc/admin.py in main()
    208    if Form.has_key('PlanetName'):
    209       orig_pass = planet.password
=>  210       planet = update_config(planet)
    211 
    212       if Form.getvalue('Timestamp') != str(planet.last_config_change):
planet = <planet.Planet instance>, global update_config = <function update_config>
 /var/www/planeteria2/www/allarounddc/admin.py in update_config(planet=<planet.Planet instance>)
    159          if not url in planet.feeds:
    160             t = {'feedurl':url, 
=>  161                  'name':good_field(Form.getvalue('name%d' % feed_count, '').strip()),
    162                  'image':Form.getvalue('image%d' % feed_count, '').strip()}
    163             planet.feeds[url] = t
global good_field = <function good_field>, global Form = FieldStorage(None, None, [MiniFieldStorage('Time...d3.jpeg'), MiniFieldStorage('Pass', '[censored]')]), Form.getvalue = <bound method FieldStorage.getvalue of FieldStor...3.jpeg'), MiniFieldStorage('Pass', '[censored]')])>, feed_count = 0, ).strip undefined

<type 'exceptions.AttributeError'>: 'list' object has no attribute 'strip'
      args = ("'list' object has no attribute 'strip'",)
      message = "'list' object has no attribute 'strip'" 

That's very helpful! Thanks for this info, I'll keep working on it.

On Mar 29, 2013, at 8:23 PM, Ken Stailey wrote:

I tried again with http://fredjoiner.wordpress.com/feed/atom/
and got
/var/www/planeteria2/www/allarounddc/admin.py in ()
227 a = Admin(template_vars(planet, Form)).render()
228 sys.stdout.write(a)
229
230 if name == "main":
=> 231 main()
main =
/var/www/planeteria2/www/allarounddc/admin.py in main()
208 if Form.has_key('PlanetName'):
209 orig_pass = planet.password
=> 210 planet = update_config(planet)
211
212 if Form.getvalue('Timestamp') != str(planet.last_config_change):
planet = , global update_config =
/var/www/planeteria2/www/allarounddc/admin.py in update_config(planet=)
159 if not url in planet.feeds:
160 t = {'feedurl':url,
=> 161 'name':good_field(Form.getvalue('name%d' % feed_count, '').strip()),
162 'image':Form.getvalue('image%d' % feed_count, '').strip()}
163 planet.feeds[url] = t
global good_field = , global Form = FieldStorage(None, None, [MiniFieldStorage('Time...d3.jpeg'), MiniFieldStorage('Pass', '[censored]')]), Form.getvalue = , feed_count = 0, ).strip undefined

<type 'exceptions.AttributeError'>: 'list' object has no attribute 'strip'
args = ("'list' object has no attribute 'strip'",)
message = "'list' object has no attribute 'strip'"

Reply to this email directly or view it on GitHub.

Form HTML contains:

    <label for="Pass">Password:</label><input type="password" size="25" name="Pass" id="Pass" value="">

Parse goes:

good_field(Form.getvalue('name%d' % feed_count, '').strip()),

but name="Pass" is not name="Pass1"

Anyhow, it shouldn't try to do planet.add_feed() on the password.

I'm now experiencing this issue as well with the WFS planet; same traceback as @nutznboltz when he added the fredjoiner blog (above).

@nutznboltz, thanks for your attention to this. I apologize for having dropped the ball, life has been a bit crazy lately! A rewrite of the admin.py file is in the plans in the next month or two, but I'd like to at least do a short-term fix for this issue so that those who are prevented from using the admin page. I'm afraid I am not going to be able to take a look at it for a couple weeks still, would you be interested in taking on this issue?

I've found the culprit! Comparing the three planets that I know have experienced this issue (wfs, feministhackers, allarounddc), it seems all of them first experienced the issue when making a change AFTER having added a feed with an apostrophe in the name. The apostrophe was being interpreted to signify the end of the string, which was throwing a wrench in things.

I've made a small change so that it escapes the apostrophes in the Name field with b4cb5f9.

This prevents the issue from happening with feeds added moving forward, however this does not fix the existing feed names in the database with unescaped apostrophes. I'm leaving this bug open until that's addressed, since those planets which are affected are still broken (cannot add any new feeds).

Upon further testing, it seems no changes to the database are needed. In my local install, I can now update planets that previously got errors. Closing this bug!