

from app.context import models
from lib.exceptions import *


def ressourceConstraints(self, value):
    ressource = value.lower().capitalize()
    if not models.get(ressource):
        raise Core400Exception("Ressource '{}' doesn't exist.".format(ressource))
    return ressource



from app.context import models
from lib.exceptions import *


def ressourceConstraints(self, value):
    ressource = value.lower().capitalize()
    if not models.get(ressource):
        raise Core400Exception("Ressource '{}' doesn't exist.".format(ressource))
    return ressource


def write(self):
    # Test if ressource is hookable before performing normal process
    if models.get(self.ressource)._hookable:
        super(self.__class__, self).write()
    else:
        raise Core400Exception("Ressource '{}' is not hookable.".format(self.ressource))


def update(self, data2save, domain):
    # Test if ressource is hookable before performing normal process
    if models.get(self.ressource)._hookable:
        super(self.__class__, self).update(data2save, domain)
    else:
        raise Core400Exception("Ressource '{}' is not hookable.".format(self.ressource))

Test if ressource is hookable before write/update
Test if ressource is hookable before write/update

  
  
  from app.context import models
  from lib.exceptions import *
  
  
  def ressourceConstraints(self, value):
      ressource = value.lower().capitalize()
      if not models.get(ressource):
          raise Core400Exception("Ressource '{}' doesn't exist.".format(ressource))
      return ressource
  
+ 
+ def write(self):
+     # Test if ressource is hookable before performing normal process
+     if models.get(self.ressource)._hookable:
+         super(self.__class__, self).write()
+     else:
+         raise Core400Exception("Ressource '{}' is not hookable.".format(self.ressource))
+ 
+ 
+ def update(self, data2save, domain):
+     # Test if ressource is hookable before performing normal process
+     if models.get(self.ressource)._hookable:
+         super(self.__class__, self).update(data2save, domain)
+     else:
+         raise Core400Exception("Ressource '{}' is not hookable.".format(self.ressource))
+ 
Test if ressource is hookable before write/update
## Code Before:


from app.context import models
from lib.exceptions import *


def ressourceConstraints(self, value):
    ressource = value.lower().capitalize()
    if not models.get(ressource):
        raise Core400Exception("Ressource '{}' doesn't exist.".format(ressource))
    return ressource

## Instruction:
Test if ressource is hookable before write/update
## Code After:


from app.context import models
from lib.exceptions import *


def ressourceConstraints(self, value):
    ressource = value.lower().capitalize()
    if not models.get(ressource):
        raise Core400Exception("Ressource '{}' doesn't exist.".format(ressource))
    return ressource


def write(self):
    # Test if ressource is hookable before performing normal process
    if models.get(self.ressource)._hookable:
        super(self.__class__, self).write()
    else:
        raise Core400Exception("Ressource '{}' is not hookable.".format(self.ressource))


def update(self, data2save, domain):
    # Test if ressource is hookable before performing normal process
    if models.get(self.ressource)._hookable:
        super(self.__class__, self).update(data2save, domain)
    else:
        raise Core400Exception("Ressource '{}' is not hookable.".format(self.ressource))
