Skip to main content

Package contatins all italian enti territoriali in sqlite db

Project description

Introduction

This package provides vocabulary for all italian ‘enti territoriali’. For storage we are using sqlite3 database wrapped with sqlalchemy.

First lets import the vocabulary (which should have already a vocabulary object):

>>> from redturtle.entiterritoriali import EntiVocabulary as EV

Now let’s try the simple query: for regione, provincia and comune:

>>> EV.regione('Emilia-Romagna')
MappedRegioni(regione=u'Emilia-Romagna',...)

>>> EV.provincia('Ferrara')
MappedProvince(provincia=u'Ferrara',...)

>>> EV.comune('Ferrara')
MappedComuni(comune_id=4105,comune=u'Ferrara',...)

Then let’s check if we have all of them:

>>> len(EV.allRegioni())
20

>>> len(EV.allProvince())
108

>>> len(EV.allComuni())
8101

Now we can try to use like statesment. We can use helper methods:

>>> EV.comuniByLetter('Mod')
[MappedComuni(comune_id=4013,comune=u'Modena',provincia=u'MO',...u'http://www.comune.modugno.ba.it/')]

>>> EV.provinceByLetter('Bo')
[MappedProvince(provincia=u'Bologna',...u'http://www.provinz.bz.it/')]

>>> EV.regioniByLetter('L')
[MappedRegioni(regione=u'Lazio',capoluogo=u'Roma'...u'postaweb@regione.lombardia.it')]

… but you can also build your own filters using sqlalchemy and pass them as list of arguments:

>>> sql_filter1 = (EV.engine.comuni.provincia == 'BO')
>>> sql_filter2 = (EV.engine.comuni.comune.like('Gal%'))
>>> EV.comuni([sql_filter1, sql_filter2])
[MappedComuni(comune_id=4065,comune=u'Galliera',...http://www.comune.galliera.bo.it/')]

You can find more at http://www.sqlalchemy.org/docs/05/ormtutorial.html#querying

Now some more advanced querying - getting all comuni for provincia:

>>> EV.comuni4provincia('BO')
[MappedComuni(comune_id=4038,comune=u"Anzola dell'Emilia"...u'http://www.comune.zolapredosa.bo.it/')]

and all province for given regione:

>>> EV.province4regione('03') #Lombardia
[MappedProvince(provincia=u'Bergamo',...sito_provincia=u'http://www.provincia.va.it/')]

Finally we can also map vocabulary to DisplayList (for Archetypes use case):

>>> from redturtle.entiterritoriali.vocabulary import mapDisplayList
>>> mapDisplayList(EV.allRegioni())
[(u'13', u'Abruzzo'), (u'17', u'Basilicata'),...(u'05', u'Veneto')]

But it should work also for different enti in one vocabulary, like here:

>>> regione1 = EV.regione('Lombardia')
>>> comune1 = EV.comune('Ferrara')
>>> enti = [regione1,comune1]
>>> mapDisplayList(enti)
[(u'03', u'Lombardia'), (u'038008', u'Ferrara')]

Credits

Developed with the support of Regione Emilia Romagna; Regione Emilia Romagna supports the PloneGov initiative.

Authors

This product was developed by RedTurtle Technology team.

RedTurtle Technology Site

Data credits

ISTAT - logo

HISTORY

0.4.0 (2016-08-02)

  • update new Emilia-Romagna merged comuni [cekk]

0.3.3 (2014-11-10)

  • fix massafiscaglia site url [cekk]

0.3.2 (2014-11-07)

  • fix import for sqlsoup [cekk]

0.3.1 (2014-11-07)

  • updated with new italian districts [cekk]

0.3 (2013-12-16)

  • compatibility with SQLAlchemy 0.8 [amleczko]

0.2.2 (2013-11-12)

  • fixed site url for Zerba [cekk]

0.2.1 (2013-08-20)

  • fixed codice istat for Casteldelci, Maiolo, Novafeltria, Pennabilli, San Leo, Sant’Agata Feltria, Talamello [cekk]

0.2 (2011-08-03)

  • cleanup, docs update [amleczko]

0.1.10 (2011-07-08)

  • fixed bertinoro website [cekk]

0.1.9 (2011-05-16)

  • fixed casalfiumanese website [cekk]

0.1.8 (2011-04-18)

  • fixed some other websites [cekk]

0.1.7 (2011-04-08)

  • fixed some other websites [cekk]

0.1.6 (2011-03-28)

  • fixed other websites for some comuni [cekk]

0.1.5 (2011-03-21)

  • added new websites for some comuni [cekk]

0.1.4 (2010-09-01)

  • declaring egg zip unsafe, otherwise it is not possible to access sqllite db [alert]

0.1.3 (2010-08-31)

  • UTF-8 fixes [keul]

0.1.2 (2009-10-09)

  • move Casteldelci, Maiolo, Novafeltria, Pennabilli, San Leo, Sant’Agata Feltria and Talamello to Rimini province [amleczko]

0.1.1 (2009-10-06)

  • SQLite3Vocab is now singleton - you should always use ‘from redturtle.entiterritoriali import EntiVocabulary’ not SQLite3Vocab directly [amleczko]

0.1.0 (2009-07-07)

  • Refactoring [amleczko]

0.0.4 (2009-06-24)

  • Add Monza e della Brianza province [amleczko]

0.0.3 (2009-06-11)

  • Add EntiCriteria (topic criteria) and all functionality behind it [amleczko]

0.0.2 (2009-05-24)

  • Add the “comuniByLetter” method used to catch comuni that start with one or more character [lucabel]

0.0.1 (2009-04-20)

  • First release [amleczko]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redturtle.entiterritoriali-0.4.0.tar.gz (229.4 kB view details)

Uploaded Source

File details

Details for the file redturtle.entiterritoriali-0.4.0.tar.gz.

File metadata

File hashes

Hashes for redturtle.entiterritoriali-0.4.0.tar.gz
Algorithm Hash digest
SHA256 22106dae64e0023b75d62b3c4df5b23ed02725f4a3811773b77fb185ef01c8b5
MD5 cd261897c570c6b671c5fa800742edfe
BLAKE2b-256 f9ef82ee035bab268cf319f8d0952e19f331a3e31dedcc136ac8855e069e1822

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page