選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

53 行
923 B

  1. class BaseModel:
  2. """
  3. New style models will be inherited from this base model class
  4. This will contain methods for save update
  5. Standard attributes:
  6. _type
  7. _id
  8. _created_by
  9. _created_on
  10. _modified_by
  11. _modified_on
  12. """
  13. def __init__(self, model_type = None, model_id = None, attributes = {}):
  14. self._type = model_type
  15. self._id = model_id
  16. if attributes:
  17. self.__dict__.update(attributes)
  18. def __getattr__(self, name):
  19. """
  20. Getter is overridden so that it does not throw an exception
  21. """
  22. if name in self.__dict__:
  23. return self.__dict__[name]
  24. else:
  25. return None
  26. def _read(self):
  27. """
  28. Read
  29. """
  30. self.__dict__.update(webnotes.conn.sql("""
  31. select * from `%s` where _id=%s
  32. """, (self._type, self._id), as_dict=1)[0])
  33. def _create(self):
  34. """
  35. Create
  36. """
  37. pass
  38. def _update(self):
  39. """
  40. Update
  41. """
  42. pass
  43. def _delete(self):
  44. """
  45. Delete
  46. """
  47. pass