No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.py 978B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. from lodel.auth.exceptions import AuthenticationError
  3. from lodel.plugin import LodelHook
  4. from .filesystem_session_store import FileSystemSession
  5. ## @brief starts a new session and returns its sid
  6. # @param caller *
  7. # @param payload dict
  8. # @return str
  9. @LodelHook('session_start')
  10. def start_session(caller, payload):
  11. new_session = FileSystemSession(content=payload)
  12. return new_session.sid
  13. '''
  14. ## @brief destroys a session
  15. # @param caller *
  16. # @param sid str : session id
  17. @LodelHook('session_destroy')
  18. def stop_session(caller, sid):
  19. FileSystemSession.destroy(sid)
  20. '''
  21. ## @brief reads a session content
  22. # @param caller *
  23. # @param sid str: session id
  24. # @return FileSystemSession
  25. @LodelHook('session_load')
  26. def read_session(caller, sid):
  27. return FileSystemSession.load(sid)
  28. '''
  29. ## @brief destroys all the old sessions (expired ones)
  30. # @param caller *
  31. @LodelHook('session_clean')
  32. def clean_sessions(caller):
  33. FileSystemSession.clean()
  34. '''