database.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #============================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. #============================================================================
  17. # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
  18. #============================================================================
  19. from pwman.data.nodes import Node
  20. from pwman.util.crypto import CryptoEngine
  21. class DatabaseException(Exception):
  22. pass
  23. class Database:
  24. def __init__(self):
  25. self._filtertags = []
  26. def open(self):
  27. """Open the database."""
  28. self._open()
  29. enc = CryptoEngine.get()
  30. key = self.loadkey()
  31. if (key != None):
  32. enc.set_cryptedkey(key)
  33. else:
  34. self.changepassword()
  35. def close(self):
  36. pass
  37. def changepassword(self):
  38. """Change the databases password."""
  39. enc = CryptoEngine.get()
  40. newkey = enc.changepassword()
  41. return self.savekey(newkey)
  42. def listtags(self, all=False):
  43. pass
  44. def currenttags(self):
  45. return self._filtertags
  46. def filter(self, tags):
  47. for t in tags:
  48. if not (t in self._filtertags):
  49. self._filtertags.append(t)
  50. def clearfilter(self):
  51. self._filtertags = []
  52. def getnodes(self, ids):
  53. pass
  54. def addnodes(self, nodes):
  55. pass
  56. def editnode(self, id, node):
  57. pass
  58. def removenodes(self, nodes):
  59. pass
  60. def listnodes(self):
  61. pass
  62. def savekey(self, key):
  63. pass
  64. def loadkey(self):
  65. pass