use the new add_field() method to define fields

This commit is contained in:
Romain Bignon 2010-10-08 13:43:23 +02:00
commit 92c6507f71
14 changed files with 133 additions and 178 deletions

View file

@ -19,23 +19,23 @@
from .base import IBaseCap, CapBaseObject
__all__ = ('IpLocation', 'ICapGeolocIp')
__all__ = ['IpLocation', 'ICapGeolocIp']
class IpLocation(CapBaseObject):
FIELDS = ('city', 'region', 'zipcode', 'country', 'lt', 'lg', 'host', 'tls', 'isp')
def __init__(self, ipaddr):
CapBaseObject.__init__(self, ipaddr)
self.ipaddr = ipaddr
self.city = None
self.region = None
self.zipcode = None
self.country = None
self.lt = None
self.lg = None
self.host = None
self.tld = None
self.isp = None
self.add_field('city', (str,unicode))
self.add_field('region', (str,unicode))
self.add_field('zipcode', (str,unicode))
self.add_field('country', (str,unicode))
self.add_field('lt', float)
self.add_field('lg', float)
self.add_field('host', (str,unicode))
self.add_field('tld', (str,unicode))
self.add_field('isp', (str,unicode))
class ICapGeolocIp(IBaseCap):
def get_location(self, ipaddr):