log.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from models import FilterFieldType
  4. from models import ORM
  5. __author__ = 'James Iter'
  6. __date__ = '2017/4/8'
  7. __contact__ = 'james.iter.cn@gmail.com'
  8. __copyright__ = '(c) 2017 by James Iter.'
  9. class Log(ORM):
  10. _table_name = 'log'
  11. _primary_key = 'id'
  12. def __init__(self, **kwargs):
  13. super(Log, self).__init__()
  14. self.id = 0
  15. self.type = kwargs.get('type', None)
  16. self.timestamp = kwargs.get('timestamp', 0)
  17. self.host = kwargs.get('host', None)
  18. self.message = kwargs.get('message', None)
  19. def set(self, **kwargs):
  20. self.type = kwargs.get('type', None)
  21. self.timestamp = kwargs.get('timestamp', 0)
  22. self.host = kwargs.get('host', None)
  23. self.message = kwargs.get('message', None)
  24. @staticmethod
  25. def get_filter_keywords():
  26. return {
  27. 'type': FilterFieldType.INT.value,
  28. 'timestamp': FilterFieldType.INT.value,
  29. 'host': FilterFieldType.STR.value
  30. }
  31. @staticmethod
  32. def get_allow_update_keywords():
  33. return []
  34. @staticmethod
  35. def get_allow_content_search_keywords():
  36. return ['host']