Add comments and additional docstrings to some functions on events module.
parent
4acb59e3cf
commit
c8bacee06c
|
@ -3,6 +3,8 @@ import json
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from . import backends
|
||||
|
||||
# The complete list of content types
|
||||
# of allowed models for change events
|
||||
watched_types = (
|
||||
("userstories", "userstory"),
|
||||
("issues", "issue"),
|
||||
|
@ -10,6 +12,9 @@ watched_types = (
|
|||
|
||||
|
||||
def _get_type_for_model(model_instance):
|
||||
"""
|
||||
Get content type tuple from model instance.
|
||||
"""
|
||||
ct = ContentType.objects.get_for_model(model_instance)
|
||||
return (ct.app_label, ct.model)
|
||||
|
||||
|
|
|
@ -3,7 +3,17 @@ import threading
|
|||
_local = threading.local()
|
||||
_local.session_id = None
|
||||
|
||||
def get_current_session_id():
|
||||
|
||||
def get_current_session_id() -> str:
|
||||
"""
|
||||
Get current session id for current
|
||||
request.
|
||||
|
||||
This function should be used only whithin
|
||||
request context. Out of request context
|
||||
it always return None
|
||||
"""
|
||||
|
||||
global _local
|
||||
if not hasattr(_local, "session_id"):
|
||||
raise RuntimeException("No session identifier is found, "
|
||||
|
@ -18,6 +28,7 @@ class SessionIDMiddleware(object):
|
|||
identifier to thread local storage (that only avaliable for
|
||||
current thread).
|
||||
"""
|
||||
|
||||
def process_request(self, request):
|
||||
global _local
|
||||
session_id = request.META.get("HTTP_X_SESSION_ID", None)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from django.db.models import signals
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
|
Loading…
Reference in New Issue