Exemplo n.º 1
0
  def prevalidate(self):
    try:
      if int(self.attrs.getValue((None, 'length'))) <= 0:
        self.log(InvalidIntegerAttribute({"parent":self.parent.name, "element":self.name, "attr":'length'}))
      else:
        self.log(ValidIntegerAttribute({"parent":self.parent.name, "element":self.name, "attr":'length'}))
    except KeyError:
      self.log(MissingAttribute({"parent":self.parent.name, "element":self.name, "attr":'length'}))
    except ValueError:
      self.log(InvalidIntegerAttribute({"parent":self.parent.name, "element":self.name, "attr":'length'}))

    try:
      if not self.mime_re.match(self.attrs.getValue((None, 'type'))):
        self.log(InvalidMIMEAttribute({"parent":self.parent.name, "element":self.name, "attr":'type'}))
      else:
        self.log(ValidMIMEAttribute({"parent":self.parent.name, "element":self.name, "attr":'type'}))
    except KeyError:
      self.log(MissingAttribute({"parent":self.parent.name, "element":self.name, "attr":'type'}))

    if self.attrs.has_key((None,u"url")):
      self.validateHttpURL(None, 'url')
      if hasattr(self.parent,'setEnclosure'): 
        self.parent.setEnclosure(self.attrs.getValue((None, 'url')))
    else:
      self.log(MissingAttribute({"parent":self.parent.name, "element":self.name, "attr":'url'}))

    return validatorBase.prevalidate(self)
Exemplo n.º 2
0
    def prevalidate(self):
        if (None, "domain") not in self.attrs.getNames():
            self.log(MissingAttribute({"parent": self.parent.name, "element": self.name, "attr": "domain"}))
        else:
            self.log(ValidCloud({"parent": self.parent.name, "element": self.name, "attr": "domain"}))

        try:
            if int(self.attrs.getValue((None, "port"))) <= 0:
                self.log(InvalidIntegerAttribute({"parent": self.parent.name, "element": self.name, "attr": "port"}))
            else:
                self.log(ValidCloud({"parent": self.parent.name, "element": self.name, "attr": "port"}))
        except KeyError:
            self.log(MissingAttribute({"parent": self.parent.name, "element": self.name, "attr": "port"}))
        except ValueError:
            self.log(InvalidIntegerAttribute({"parent": self.parent.name, "element": self.name, "attr": "port"}))

        if (None, "path") not in self.attrs.getNames():
            self.log(MissingAttribute({"parent": self.parent.name, "element": self.name, "attr": "path"}))
        else:
            self.log(ValidCloud({"parent": self.parent.name, "element": self.name, "attr": "path"}))

        if (None, "registerProcedure") not in self.attrs.getNames():
            self.log(MissingAttribute({"parent": self.parent.name, "element": self.name, "attr": "registerProcedure"}))
        else:
            self.log(ValidCloud({"parent": self.parent.name, "element": self.name, "attr": "registerProcedure"}))

        if (None, "protocol") not in self.attrs.getNames():
            self.log(MissingAttribute({"parent": self.parent.name, "element": self.name, "attr": "protocol"}))
        else:
            self.log(ValidCloud({"parent": self.parent.name, "element": self.name, "attr": "protocol"}))
        ## TODO - is there a list of accepted protocols for this thing?

        return validatorBase.prevalidate(self)
Exemplo n.º 3
0
  def prevalidate(self):
    try:
      if int(self.attrs.getValue((None, 'length'))) < 0:
        if int(self.attrs.getValue((None, 'length'))) == -1:
          self.log(UseZeroForUnknown({"parent":self.name, "element":'length'}))
        else:
          self.log(InvalidNonNegativeInteger({"parent":self.name, "element":'length'}))
      else:
        self.log(ValidIntegerAttribute({"parent":self.parent.name, "element":self.name, "attr":'length'}))
    except KeyError:
      self.log(MissingAttribute({"parent":self.parent.name, "element":self.name, "attr":'length'}))
    except ValueError:
      self.log(InvalidIntegerAttribute({"parent":self.parent.name, "element":self.name, "attr":'length'}))

    try:
      if not self.mime_re.match(self.attrs.getValue((None, 'type'))):
        self.log(InvalidMIMEAttribute({"parent":self.parent.name, "element":self.name, "attr":'type'}))
      else:
        self.log(ValidMIMEAttribute({"parent":self.parent.name, "element":self.name, "attr":'type'}))
    except KeyError:
      self.log(MissingAttribute({"parent":self.parent.name, "element":self.name, "attr":'type'}))

    self.validate_required_attribute((None,'url'), httpURL)
    if self.attrs.has_key((None,u"url")):
      if hasattr(self.parent,'setEnclosure'):
        self.parent.setEnclosure(self.attrs.getValue((None, 'url')))

    return validatorBase.prevalidate(self)
Exemplo n.º 4
0
    def prevalidate(self):
        if (None, 'domain') not in self.attrs.getNames():
            self.log(
                MissingAttribute({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": "domain"
                }))
        else:
            self.log(
                ValidCloud({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": "domain"
                }))

        try:
            if int(self.attrs.getValue((None, 'port'))) <= 0:
                self.log(
                    InvalidIntegerAttribute({
                        "parent": self.parent.name,
                        "element": self.name,
                        "attr": 'port'
                    }))
            else:
                self.log(
                    ValidCloud({
                        "parent": self.parent.name,
                        "element": self.name,
                        "attr": 'port'
                    }))
        except KeyError:
            self.log(
                MissingAttribute({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": 'port'
                }))
        except ValueError:
            self.log(
                InvalidIntegerAttribute({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": 'port'
                }))

        if (None, 'path') not in self.attrs.getNames():
            self.log(
                MissingAttribute({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": "path"
                }))
        else:
            self.log(
                ValidCloud({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": "path"
                }))

        if (None, 'registerProcedure') not in self.attrs.getNames():
            self.log(
                MissingAttribute({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": "registerProcedure"
                }))
        else:
            self.log(
                ValidCloud({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": "registerProcedure"
                }))

        if (None, 'protocol') not in self.attrs.getNames():
            self.log(
                MissingAttribute({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": "protocol"
                }))
        else:
            self.log(
                ValidCloud({
                    "parent": self.parent.name,
                    "element": self.name,
                    "attr": "protocol"
                }))
        ## TODO - is there a list of accepted protocols for this thing?

        return validatorBase.prevalidate(self)