old_contents: from urllib2 import HTTPError
  from geoserver.support import atom_link, get_xml
  from geoserver.style import Style
  from geoserver.resource import FeatureType, Coverage
  
  class Layer: 
    def __init__(self, node):
      self.name = node.find("name").text
      self.href = atom_link(node)
      self.update()
  
    def update(self):
      try: 
        layer = get_xml(self.href)
        self.name = layer.find("name").text
        self.attribution = layer.find("attribution").text
        self.enabled = layer.find("enabled").text == "true"
        self.default_style = Style(layer.find("defaultStyle"))
        resource = layer.find("resource")
        if resource and "class" in resource.attrib:
          if resource.attrib["class"] == "featureType":
            self.resource = FeatureType(resource)
          elif resource.attrib["class"] == "coverage":
            self.resource = Coverage(resource)
      except HTTPError, e:
        print e.geturl()
  
    def __repr__(self):
      return "Layer[%s]" % self.name
  
new_contents: from urllib2 import HTTPError
  from geoserver.support import ResourceInfo, atom_link, get_xml
  from geoserver.style import Style
  from geoserver.resource import FeatureType, Coverage
  
  class Layer(ResourceInfo): 
    resource_type = "layers"
  
    def __init__(self, node):
      self.name = node.find("name").text
      self.href = atom_link(node)
      self.update()
  
    def update(self):
      ResourceInfo.update(self)
      name = self.metadata.find("name")
      attribution = self.metadata.find("attribution")
      enabled = self.metadata.find("enabled")
      default_style = self.metadata.find("defaultStyle")
  
      if name is not None:
        self.name = name.text
      else:
        self.name = None
      
      if attribution is not None:
        self.attribution = attribution.text
      else:
        self.attribution = None
  
      if enabled is not None and enabled.text == "true":
        self.enabled = True
      else:
        self.enabled = False
  
      if default_style is not None:
        self.default_style = Style(default_style)
      else:
        self.default_style = None
  
      resource = self.metadata.find("resource")
      if resource and "class" in resource.attrib:
        if resource.attrib["class"] == "featureType":
          self.resource = FeatureType(resource)
        elif resource.attrib["class"] == "coverage":
          self.resource = Coverage(resource)
  
    def __repr__(self):
      return "Layer[%s]" % self.name
  
subject: Update Layer to use ResourceInfo support class