Michael Hall has proposed merging lp:~mhall119/loco-directory/update-feed-proxy 
into lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)

For more details, see:
https://code.launchpad.net/~mhall119/loco-directory/update-feed-proxy/+merge/73614

Adds a check for settings.HTTP_PROXY and will use that value to proxy 
feedparser's connections though another host.

IS will need to add this setting to their local_settings.py file on the server.
-- 
https://code.launchpad.net/~mhall119/loco-directory/update-feed-proxy/+merge/73614
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~mhall119/loco-directory/update-feed-proxy into lp:loco-directory.
=== modified file 'loco_directory/articles/models.py'
--- loco_directory/articles/models.py	2011-08-26 19:54:59 +0000
+++ loco_directory/articles/models.py	2011-09-01 00:28:22 +0000
@@ -3,10 +3,12 @@
 import time
 import datetime
 import socket
+import urllib2
 
 from django.db import models
 from django.contrib.auth.models import User
 from django.utils.html import strip_tags
+from django.conf import settings
 
 from teams.models import Team
 from userprofiles.models import UserProfile
@@ -33,7 +35,7 @@
 class Feed(models.Model):
     user = models.ForeignKey(UserProfile, blank=True, null=True)
     team = models.ForeignKey(Team, blank=True, null=True)
-    url = models.URLField()
+    url = models.URLField(verify_exists=False)
     title = models.CharField(max_length=128, null=True, blank=True)
     last_updated = models.DateTimeField(null=False, blank=False, default=datetime.datetime(1970, 1, 1))
     active = models.BooleanField(default=True)
@@ -48,7 +50,11 @@
         if not data:
             old_timeout = socket.getdefaulttimeout()
             socket.setdefaulttimeout(20)
-            data = feedparser.parse(self.url, modified=self.last_updated.utctimetuple())
+            handlers = []
+            proxy = getattr(settings, 'HTTP_PROXY', None)
+            if proxy:
+                handlers.append(urllib2.ProxyHandler( {"http": proxy} ))
+            data = feedparser.parse(self.url, modified=self.last_updated.utctimetuple(), handlers=handlers)
             socket.setdefaulttimeout(old_timeout)
             
         if not data or not hasattr(data, 'entries') or len(data.entries) == 0:

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to