![]() |
#1 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Aug 2011
Device: Kindle 3
|
Request: International Viewpoint
http://www.internationalviewpoint.or...p?page=backend
I just can't make it work. I tried to make it get the print versions but couldn't. I'm a newbie. Any help is welcome! |
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
|
|
![]() |
![]() |
![]() |
#3 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Aug 2011
Device: Kindle 3
|
This is what I tried to do:
RSS: http://www.internationalviewpoint.or...p?page=backend Article: http://www.internationalviewpoint.or...hp?article2242 Print version: http://www.internationalviewpoint.or...d_article=2242 Code I used: Code:
class AdvancedUserRecipe1313445974(BasicNewsRecipe): title = u'International Viewpoint' oldest_article = 90 max_articles_per_feed = 100 feeds = [(u'Articles', u'http://www.internationalviewpoint.org/spip.php?page=backend')] def print_version(self, url): return url.replace('http://www.internationalviewpoint.org/spip.php?article', 'http://www.internationalviewpoint.org/spip.php?page=print_article&id_article=') Last edited by Starson17; 08-17-2011 at 09:37 AM. Reason: add code tags |
![]() |
![]() |
![]() |
#4 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
def print_version(self, url): So that code is outside the class AdvancedUserRecipe1313445974(BasicNewsRecipe): and is never run. Indent it the same amount as title = u'International Viewpoint' and indent everything below it the same additional amount. |
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Aug 2011
Device: Kindle 3
|
Thank you very much! I don't know what indent means but I'll look it up!
|
![]() |
![]() |
![]() |
#6 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
Code:
class AdvancedUserRecipe1313445974(BasicNewsRecipe): title = u'International Viewpoint' oldest_article = 90 max_articles_per_feed = 100 feeds = [(u'Articles', u'http://www.internationalviewpoint.org/spip.php?page=backend')] def print_version(self, url): return url.replace('http://www.internationalviewpoint.org/spip.php?article', 'http://www.internationalviewpoint.org/spip.php?page=print_article&id_article=') |
|
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,306
Karma: 78876004
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
Unlike many programming tools that use BEGIN / END or { } to group together sections of code, Python uses spaces or indentation to make the same sections of code.
So for instance C might do Code:
printf("before if\n"); if ( a == 0) { printf("a is zero\n"); } else { printf("a is non zero\n"); } printf("end of if\n"); Code:
print "before if" if a == 0: print "a is zero" else: print "a is not zero" print "after if" |
![]() |
![]() |
![]() |
#8 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
And to explain further: In the case of a recipe, the print_version code has to be part of the AvancedUserRecipe group of code ("class"). The originally posted recipe had def print version at the same level of indent as AvancedUserRecipe, so it wasn't part of the recipe class and wasn't being processed. It was being ignored.
|
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Aug 2011
Device: Kindle 3
|
Well, just for the record, it's working like a charm now! Maybe some improvements are possible, but it suits me. Thank you all!
Code:
class AdvancedUserRecipe1313445974(BasicNewsRecipe): title = u'International Viewpoint 4' oldest_article = 90 max_articles_per_feed = 100 feeds = [(u'Articles', u'http://www.internationalviewpoint.org/spip.php?page=backend')] def print_version(self, url): return url.replace('http://www.internationalviewpoint.org/spip.php?article', 'http://www.internationalviewpoint.org/spip.php?page=print_article&id_article=') |
![]() |
![]() |
![]() |
#10 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Questions about mixed viewpoint stories | Steven Lake | Writers' Corner | 10 | 10-19-2010 11:24 PM |
Is my K2 International? | Aeroraptor | Amazon Kindle | 13 | 12-13-2009 03:49 PM |
Science Fiction Garrett, Randall: Viewpoint. V1. 8 Jan 2008 | Xenophon | BBeB/LRF Books (offline) | 0 | 01-08-2008 05:10 PM |
Sony taking DRM too far from a programmer's viewpoint | Colin Dunstan | News | 9 | 11-10-2005 04:50 AM |