Skip to content
Snippets Groups Projects
Commit b5d5b599 authored by Frits Sweijen's avatar Frits Sweijen
Browse files

Change __setitem__ calls to []

parent 80d7bacd
No related branches found
No related tags found
1 merge request!5Update design doc picas api
......@@ -129,14 +129,14 @@ class Token(dict):
using the python __get__ method, i.e. token['field']. Each token has a token_id that is unique
in the database, which it is part of, however the database interface is only defined in the
child classes of Token"""
self.__setitem__("type", token_type)
self['type'] = token_type
if not token_id:
self.__setitem__("_id", token_type)
self['_id'] = token_type
else:
self.__setitem__("_id", token_id)
self.__setitem__("PICAS_API_VERSION", GRID_LRT.__version__)
self.__setitem__("lock", 0)
self.__setitem__("done", 0)
self['_id'] = token_id
self['PICAS_API_VERSION'] = GRID_LRT.__version__
self['lock'] = 0
self['done'] = 0
@property
def database(self):
......@@ -173,15 +173,15 @@ class Token(dict):
"""General interface to 'reset' a Token as defined in PiCaS Standards.
The lock and done fields are timestamps and if are set to 0, the token will be
considered in the 'todo' state"""
self.__setitem__("lock", 0)
self.__setitem__("done", 0)
self['lock'] = 0
self['done'] = 0
scrub_count = self.get(
"scrub_count", 0
) ##TODO: Get function override to get from db
self.__setitem__("scrub_count", scrub_count + 1)
self.__setitem__("hostname", "")
self.__setitem__("output", "")
self.__setitem__("status", "reset")
self['scrub_count'] = scrub_count + 1
self['hostname'] = ''
self['output'] = ''
self['status'] = 'reset'
def archive(self, delete=False):
"""Archives all tokens, given a database. Deletes them if the delete flag is set to True"""
......@@ -330,7 +330,7 @@ class TokenList(list):
if design_doc_name not in self.database:
self._design_doc.save()
self._design_doc.fetch()
self._design_doc.__setitem__("PICAS_API_VERSION", GRID_LRT.__version__)
self._design_doc['PICAS_API_VERSION'] = GRID_LRT.__version__
self._design_doc.save()
def add_attachment(self, filename, attachment_name):
......@@ -347,7 +347,7 @@ class TokenList(list):
if isinstance(item, Token):
if 'PICAS_API_VERSION' in item:
# Custom version specified in the config file, update design doc PICAS_API_VERSION from token.
self._design_doc.__setitem__('PICAS_API_VERSION', item['PICAS_API_VERSION'])
self._design_doc['PICAS_API_VERSION'] = item['PICAS_API_VERSION']
self._design_doc.save()
if not hasattr(self, 'database'):
self.database=item.database
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment