Changeset 356

Show
Ignore:
Timestamp:
04/21/08 02:27:32 (7 months ago)
Author:
thai
Message:

update tweetsearch/py to the latest version

Location:
trunk/tutorial/tweetsearch/py
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/tutorial/tweetsearch/py/readme.txt

    r354 r356  
    88 
    99<VirtualHost *> 
    10             ServerName tweetsearch.local 
    11         DocumentRoot /path/to/thrudb/tutorial/tweetsearch 
     10        ServerName tweetsearch.local 
     11        DocumentRoot /path/to/thrudb/tutorial/tweetsearch/py 
    1212        <Location "/"> 
    1313                SetHandler python-program 
     
    1616                SetEnv  PYTHON_EGG_CACHE /tmp 
    1717                PythonDebug On 
    18                 PythonPath      "['/path/to/thrudb/tutorial'] + sys.path" 
     18                PythonPath      "['/path/to/thrudb/tutorial/py'] + sys.path" 
    1919        </Location> 
    2020 
  • trunk/tutorial/tweetsearch/py/search/template.html

    r354 r356  
    2222 
    2323{% if query %} 
    24     {{ total }} results for: <b>&quot;{{ query|escape }}&quot;</b> showing ({{ current }} - {{ next }}) 
     24    {{ total }} results for: <b>{{ query|escape }}</b> showing ({{ current }} - {{ next }}) 
    2525    <br/> 
    2626 
  • trunk/tutorial/tweetsearch/py/search/twitter.py

    r354 r356  
    1313from time import time 
    1414 
    15 import urllib2 
    16 import cjson 
    17 import sys 
    1815import socket 
    1916# timeout in seconds 
    2017TIMEOUT = 10 
    2118socket.setdefaulttimeout(TIMEOUT) 
     19import urllib2 
     20import cjson 
     21import sys 
    2222 
    2323# Config Constants 
     
    8181                json = response.read() 
    8282                tweets = cjson.decode(json) 
    83             except: 
     83            except Exception, e: 
     84                print e                 
    8485                continue                
    8586            for tweet in tweets: 
    8687                # somehow sometimes tweet is not a dictionary, check to make sure 
    8788                if isinstance(tweet, dict): 
     89                    # if sth serious wrong happened in thrudb, better to log it and continue 
    8890                    try: 
    8991                        self.index_tweet(tweet) 
     
    9193                        self.count = self.count + 1 
    9294                        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                                                                 
    9697                        continue  
    9798            print "loaded %s tweets, last since_id %s" % (self.count, self.since_id) 
     
    121122        q = ThrudexTypes.SearchQuery() 
    122123        q.index = THRUDEX_INDEX 
    123         q.query = "+text:(%s)" % terms 
     124        q.query = '+text:(%s)' % terms 
    124125        q.offset = offset 
    125126        q.limit = limit 
  • trunk/tutorial/tweetsearch/py/search/views.py

    r354 r356  
    88def search(request): 
    99    query = request.GET.get('q', '').encode('utf-8') 
    10     offset = request.GET.get('offset', '') 
     10    offset = request.GET.get('offset', 0) 
    1111    if offset: 
    12         offset = int(offset) 
    13     else: 
    14         offset = 0 
     12        offset = int(offset)   
    1513    tweets = None 
    1614    total = None