hawat.blueprints.geoip package¶
This pluggable module provides access to local IP geolocation service. It is
implemented upon custom mentat.services.geoip
module, which in turn uses
the geolocation service GeoLite2
created by MaxMind. This module requires that GeoLite2
database files are installed locally on host machine.
Provided endpoints¶
/geoip/search
Endpoint providing search form for querying local IP geolocation service and formating result as HTML page.
Authentication: login required
Methods:
GET
/api/geoip/search
Endpoint providing API search form for querying local IP geolocation service and formating result as JSON document.
Authentication: login required
Authorization: any role
Methods:
GET
,POST
/snippet/geoip/search
Endpoint providing API search form for querying local IP geolocation service and formating result as JSON document containing HTML snippets.
Authentication: login required
Authorization: any role
Methods:
GET
,POST
-
class
hawat.blueprints.geoip.
APISearchView
[source]¶ Bases:
hawat.view.mixin.AJAXMixin
,hawat.blueprints.geoip.AbstractSearchView
View responsible for searching IP geolocation service and presenting the results in the form of JSON document.
-
classmethod
get_view_name
()[source]¶ Return unique name for the view. Name must be unique in the namespace of parent blueprint/module and should contain only characters
[a-z0-9]
. It will be used for generating endpoint name for the view.This method does not have any default implementation and must be overridden by a subclass.
- Returns
Name for the view.
- Return type
str
-
methods
: Optional[List[str]] = ['GET', 'POST']¶
-
classmethod
-
class
hawat.blueprints.geoip.
AbstractSearchView
[source]¶ Bases:
hawat.view.RenderableView
Application view providing base search capabilities for local IP geolocation service.
The geolocation is implemented using
mentat.services.geoip
module.-
authentication
= True¶
-
dispatch_request
()[source]¶ Mandatory interface required by the
flask.views.View.dispatch_request()
. Will be called by the Flask framework to service the request.
Return menu entry title for the view.
Default implementation returns the return value of
hawat.view.BaseView.get_view_title()
method by default.- Parameters
kwargs (dict) – Optional parameters.
- Returns
Menu entry title for the view.
- Return type
str
-
classmethod
get_view_title
(**kwargs)[source]¶ Return title for the view, that will be displayed in the
title
tag of HTMLhead
element and also as the content of page header inh2
tag.Default implementation returns the return value of
hawat.view.BaseView.get_menu_title()
method by default.- Parameters
kwargs (dict) – Optional parameters.
- Returns
Title for the view.
- Return type
str
-
-
hawat.blueprints.geoip.
BLUEPRINT_NAME
= 'geoip'¶ Name of the blueprint as module global constant.
-
class
hawat.blueprints.geoip.
GeoipBlueprint
(name, import_name, **kwargs)[source]¶ Bases:
hawat.base.HawatBlueprint
Pluggable module - IP geolocation service (geoip).
-
classmethod
get_module_title
()[source]¶ Get human readable name for this blueprint/module.
- Returns
Name (short summary) of the blueprint/module.
- Return type
str
-
name
= None¶
-
classmethod
-
class
hawat.blueprints.geoip.
SearchView
[source]¶ Bases:
hawat.view.mixin.HTMLMixin
,hawat.blueprints.geoip.AbstractSearchView
View responsible for searching IP geolocation service and presenting the results in the form of HTML page.
-
classmethod
get_view_name
()[source]¶ Return unique name for the view. Name must be unique in the namespace of parent blueprint/module and should contain only characters
[a-z0-9]
. It will be used for generating endpoint name for the view.This method does not have any default implementation and must be overridden by a subclass.
- Returns
Name for the view.
- Return type
str
-
methods
: Optional[List[str]] = ['GET']¶
-
classmethod
-
class
hawat.blueprints.geoip.
SnippetSearchView
[source]¶ Bases:
hawat.view.mixin.SnippetMixin
,hawat.blueprints.geoip.AbstractSearchView
View responsible for searching IP geolocation service and presenting the results in the form of JSON document containing ready to use HTML page snippets.
-
classmethod
get_view_name
()[source]¶ Return unique name for the view. Name must be unique in the namespace of parent blueprint/module and should contain only characters
[a-z0-9]
. It will be used for generating endpoint name for the view.This method does not have any default implementation and must be overridden by a subclass.
- Returns
Name for the view.
- Return type
str
-
methods
: Optional[List[str]] = ['GET', 'POST']¶
-
renders
= ['label', 'full']¶
-
snippets
= [{'name': 'city', 'condition': <function SnippetSearchView.<lambda>>}, {'name': 'asn', 'condition': <function SnippetSearchView.<lambda>>}]¶
-
classmethod