~sirn/fanboi2

ref: baf63a21556905a6c27516a8d5641d31120d1fe3 fanboi2/fanboi2/geoip.py -rw-r--r-- 336 bytes View raw
baf63a21Kridsada Thanabulpong Add scope column to banwords. 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import geoip2.database as geoip_db


def includeme(config):  # pragma: no cache
    geoip_path = config.registry.settings["geoip.path"]
    if not geoip_path:
        return

    geoip = geoip_db.Reader(geoip_path)

    def geoip_factory(context, request):
        return geoip

    config.register_service_factory(geoip, name="geoip")