kopia lustrzana https://gitlab.com/jaywink/federation
Create top level Django url config and utilities
rodzic
570f7c6007
commit
16e1b69061
|
@ -0,0 +1,6 @@
|
|||
from django.conf.urls import url
|
||||
from django.urls import include
|
||||
|
||||
urlpatterns = [
|
||||
url(r'', include("federation.hostmeta.django.urls")),
|
||||
]
|
|
@ -0,0 +1,34 @@
|
|||
import importlib
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
|
||||
def get_configuration():
|
||||
"""
|
||||
Combine defaults with the Django configuration.
|
||||
"""
|
||||
configuration = {
|
||||
"hcard_path": "/hcard/users/",
|
||||
"nodeinfo2_function": None,
|
||||
"search_path": None,
|
||||
}
|
||||
configuration.update(settings.FEDERATION)
|
||||
if not all([
|
||||
"get_profile_function" in configuration,
|
||||
"base_url" in configuration,
|
||||
]):
|
||||
raise ImproperlyConfigured("Missing required FEDERATION settings, please check documentation.")
|
||||
return configuration
|
||||
|
||||
|
||||
def get_function_from_config(item):
|
||||
"""
|
||||
Import the function to get profile by handle.
|
||||
"""
|
||||
config = get_configuration()
|
||||
func_path = config.get(item)
|
||||
module_path, func_name = func_path.rsplit(".", 1)
|
||||
module = importlib.import_module(module_path)
|
||||
func = getattr(module, func_name)
|
||||
return func
|
Ładowanie…
Reference in New Issue