Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class World(CSVFile):
- class_csv_guess = True
- columns = ['id', 'continent', 'sub_id', 'sub_continent', 'country_id',
- 'iana_root_zone', 'country', 'region', 'county']
- schema = {'id': Integer,
- 'continent': String,
- 'sub_id': Integer,
- 'sub_continent': String,
- 'country_id': Integer,
- 'iana_root_zone': String,
- 'country': String,
- 'region': Unicode,
- 'county': Unicode}
- class ImportCountries(STLForm):
- access = 'is_admin'
- title = MSG(u'Import countries')
- template = '/ui/abakuc/import.xml'
- def action(self, resource, context, form):
- country_class_id = 'country'
- rw_database = RWDatabase()
- csv = rw_database.get_handler(get_abspath('/Users/khinester/lib/python2.6/site-packages/abakuc/data/countries_austria_full.csv'), World)
- rows = csv.get_rows()
- list_countries = set()
- # List countries and its regions
- for row in rows:
- country = row.get_value('country')
- iana_root_zone = row.get_value('iana_root_zone')
- name = checkid(country)
- list_countries.add((name, country, iana_root_zone))
- list_countries = sorted(list_countries)
- from country import Country
- for x in list_countries[233:235]:
- hosts = []
- hosts.append('%s.destinationsguide.info' % x[2])
- hosts.append('%s.destinationsguide.info' % x[0])
- title = u'%s' % x[1]
- country = resource.make_resource(x[0],
- Country,
- title={'en': title},
- website_is_open='community',
- website_languages=('en', 'fr'),
- vhosts=hosts,
- description={'en':u'Country description'},
- )
Add Comment
Please, Sign In to add comment