Changeset 356
- Timestamp:
- 04/21/08 02:27:32 (7 months ago)
- Location:
- trunk/tutorial/tweetsearch/py
- Files:
-
- 4 modified
-
readme.txt (modified) (2 diffs)
-
search/template.html (modified) (1 diff)
-
search/twitter.py (modified) (4 diffs)
-
search/views.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tutorial/tweetsearch/py/readme.txt
r354 r356 8 8 9 9 <VirtualHost *> 10 ServerName tweetsearch.local11 DocumentRoot /path/to/thrudb/tutorial/tweetsearch 10 ServerName tweetsearch.local 11 DocumentRoot /path/to/thrudb/tutorial/tweetsearch/py 12 12 <Location "/"> 13 13 SetHandler python-program … … 16 16 SetEnv PYTHON_EGG_CACHE /tmp 17 17 PythonDebug On 18 PythonPath "['/path/to/thrudb/tutorial '] + sys.path"18 PythonPath "['/path/to/thrudb/tutorial/py'] + sys.path" 19 19 </Location> 20 20 -
trunk/tutorial/tweetsearch/py/search/template.html
r354 r356 22 22 23 23 {% if query %} 24 {{ total }} results for: <b> "{{ query|escape }}"</b> showing ({{ current }} - {{ next }})24 {{ total }} results for: <b>{{ query|escape }}</b> showing ({{ current }} - {{ next }}) 25 25 <br/> 26 26 -
trunk/tutorial/tweetsearch/py/search/twitter.py
r354 r356 13 13 from time import time 14 14 15 import urllib216 import cjson17 import sys18 15 import socket 19 16 # timeout in seconds 20 17 TIMEOUT = 10 21 18 socket.setdefaulttimeout(TIMEOUT) 19 import urllib2 20 import cjson 21 import sys 22 22 23 23 # Config Constants … … 81 81 json = response.read() 82 82 tweets = cjson.decode(json) 83 except: 83 except Exception, e: 84 print e 84 85 continue 85 86 for tweet in tweets: 86 87 # somehow sometimes tweet is not a dictionary, check to make sure 87 88 if isinstance(tweet, dict): 89 # if sth serious wrong happened in thrudb, better to log it and continue 88 90 try: 89 91 self.index_tweet(tweet) … … 91 93 self.count = self.count + 1 92 94 self.since_id = tweet["id"] 93 except: 94 # sth serious wrong happened in thrudb, better to raise the error and continue 95 raise 95 except Exception, e: 96 print e 96 97 continue 97 98 print "loaded %s tweets, last since_id %s" % (self.count, self.since_id) … … 121 122 q = ThrudexTypes.SearchQuery() 122 123 q.index = THRUDEX_INDEX 123 q.query = "+text:(%s)"% terms124 q.query = '+text:(%s)' % terms 124 125 q.offset = offset 125 126 q.limit = limit -
trunk/tutorial/tweetsearch/py/search/views.py
r354 r356 8 8 def search(request): 9 9 query = request.GET.get('q', '').encode('utf-8') 10 offset = request.GET.get('offset', '')10 offset = request.GET.get('offset', 0) 11 11 if offset: 12 offset = int(offset) 13 else: 14 offset = 0 12 offset = int(offset) 15 13 tweets = None 16 14 total = None
