Example #1
1
    def loadService(self, type, subtype, name, db):
        """Loads given service from data base

        Args:
            type - service type
            subtype - service subtype
            name - service name
            db - mysql database cursor

        All three parameters are necessary because only full path is guaranteed
        to be unique.
        """

        srv = getClass(type, subtype)
        if not srv:
            raise ScalakError("No such service registered: {0},{1}".format(type, subtype))
        srv = srv()

        res = db.execute(
            "select field, value from services where project=%s and\
                type=%s and subtype=%s and name=%s",
            (self.id, type, subtype, name),
        )
        tmp = []
        if res:
            tmp = db.fetchall()
            srv.load(self, name, tmp)
        self.addService(srv, True)