Changeset 195:4b2cbeabb338

Show
Ignore:
Timestamp:
09/14/08 21:58:17 (2 years ago)
Author:
rgrp
Branch:
default
convert_revision:
svn:10edda23-d834-0410-9182-b00384516d49/trunk@207
Message:

[wui,factlet][m]: minor fixes to wikipedia stuff (see r206, ticket:30) plus squashing a few bugs (e.g. location not showing in edit_form template).

  • data/napoleon.js: put in location for all factlets.
Location:
microfacts
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • microfacts/controllers/factlet.py

    r194 r195  
    6969            logger.debug('Creating new factlet from url: %s' % url) 
    7070            # TODO: check dbpedia_enabled is True? 
    71             d = microfacts.getdata.dbpedia.Describe() 
     71            d = microfacts.getdata.dbpedia.Describe(recurse_for_location=True) 
    7272            d.execute(url) 
    7373            try: 
  • microfacts/data/napoleon.js

    r183 r195  
    2929      "source" : "http://en.wikipedia.org/wiki/Battle_of_Trafalgar", 
    3030      "description" : "", 
    31       "start" : "1805-10-21" 
     31      "start" : "1805-10-21", 
     32      "location" : {"type": "Point", "coordinates": [-6.25, 36.166] } 
    3233    }, 
    3334    { 
    34       "title" : "Battle of Jena", 
    35       "source" : "http://en.wikipedia.org/wiki/Battle_of_Jena", 
    36       "start" : "1806-10-14" 
     35      "title" : "Battle of Jena-Auerstadt", 
     36      "source" : "http://en.wikipedia.org/wiki/Battle_of_Jena-Auerstedt", 
     37      "start" : "1806-10-14", 
     38      "location" : {"type": "Point", "coordinates": [50.92722, 11.58611] } 
    3739    }, 
    3840    { 
  • microfacts/getdata/dbpedia.py

    r194 r195  
    7575class Describe: 
    7676 
    77     def __init__(self, verbose=False): 
     77    def __init__(self, verbose=False, recurse_for_location=False): 
    7878        self.results = [] 
    7979        self.verbose = verbose 
    8080        self.language = 'en' 
     81        self.recurse_for_location = recurse_for_location 
    8182 
    8283    def execute(self, uri): 
     
    115116        return self.to_str() 
    116117 
    117     def extract(self, recurse_for_location=False): 
     118    def extract(self): 
    118119        kwds = { 'title' : None, 
    119120                'description' : None, 
     
    170171 
    171172        # get lat/long indirectly ... 
    172         if recurse_for_location and kwds['place'] and not kwds['long']: 
     173        if self.recurse_for_location and kwds['place'] and not kwds['long']: 
    173174            # need to retrieve long/lats from place 
    174175            for place in kwds['place']: 
    175176                # TODO: put this in debug 
    176                 # print 'Processing place', place 
     177                if self.verbose: 
     178                    print 'Processing place', place 
    177179                newd = Describe() 
    178180                newd.execute(place) 
     
    180182                # always assume if we have long have lat 
    181183                if out['long']: 
     184                    if self.verbose: 
     185                        print 'Using place data from', place 
    182186                    # should probably record which place this came from somehow 
    183187                    kwds['long'] = out['long'] 
     
    242246            kwds['image'] = kwds['image_urls'][0] 
    243247        if kwds['long']: 
    244             kwds['location'] = { 'type': 'Point', coordinates:None } 
     248            kwds['location'] = { 'type': 'Point', 'coordinates': None } 
    245249            kwds['location']['coordinates'] = [ kwds['long'], kwds['lat'] ] 
    246250        fct = conv.to_domain_object(kwds) 
  • microfacts/lib/cli.py

    r194 r195  
    136136        if cmd == 'describe': 
    137137            uri = self.args[1] 
    138             result = dbp.describe(uri, verbose=self.verbose) 
     138            d = dbp.Describe(verbose=self.verbose, 
     139                    recurse_for_location=True) 
     140            d.execute(uri) 
     141            result = str(d) 
    139142        elif cmd == 'search': 
    140143            category = self.args[1] 
  • microfacts/templates/factlet/edit_core.html

    r187 r195  
    2727        </dd> 
    2828        <dt>Location</dt> 
    29         <dd> 
    30           <label>Long:</label> ${h.text_field('location__x', value=value_of(c.factlet.location.x, None))} <br /> 
    31           <label>Lat:</label> ${h.text_field('location__y', value=value_of(c.factlet.location.y, None))} 
     29        <dd py:with="tlocation=getattr(c.factlet, 'location', None)"> 
     30          <label>Long:</label> 
     31          ${h.text_field('location__x', value=getattr(tlocation, 'x', None))} 
     32          <br /> 
     33          <label>Lat:</label> 
     34          ${h.text_field('location__y', value=getattr(tlocation, 'y', None))} 
    3235        </dd> 
    3336        <dt>Source Url</dt> 
  • microfacts/tests/functional/test_factlet.py

    r194 r195  
    110110        assert str(fct.license) in response 
    111111        assert fct.start in response 
    112         # *really* weird, value_of does not work in template now but plain 
    113         # ${c.factlet.location.x} does! 
    114         # assert fct.location.x in response 
     112        assert fct.location.x in response 
    115113        assert '<label>' in response 
    116114        # check no change to domain model ... 
  • microfacts/tests/getdata/test_dbpedia.py

    r194 r195  
    4040    def setup_class(self): 
    4141        uri3 = 'http://dbpedia.org/resource/Battle_of_Austerlitz' 
    42         self.d = Describe() 
     42        self.d = Describe(recurse_for_location=True) 
    4343        self.d.execute(uri3) 
    44         self.kwds = self.d.extract(recurse_for_location=True) 
     44        self.kwds = self.d.extract() 
    4545        self.fct = None 
    4646        self.start = datetime.datetime(1805, 12, 2)