 
     # if the attribute is not on this property object at all, log a bad request
     if not (attrname of @)
-      #console.log("requested unknown property '#{ attrname }' on object: " + obj)
+      console.log("requested selection of unknown property '#{ attrname }' on object: " + obj)
       return
 
     # if the attribute specifies a field, and the field exists on the object, return that value

      if (@[attrname].field of obj)
        return obj[@[attrname].field]

    # otherwise, if the attribute exists on the object, return that value
    if obj[attrname]?
      return obj[attrname]

    # finally, check for a default value on this property object that could be returned
    if @[attrname]? and 'default' of @[attrname]
      return @[attrname].default

    # failing that, just log a problem

class properties

  string: (styleprovider, glyphspec, attrname) ->
    @[attrname] = {}

    default_value = styleprovider.mget(attrname)
    if not default_value?
    else if _.isString(default_value)
      @[attrname].default = default_value
    else
      console.log("string property '#{ attrname }' given invalid default value: " + default_value)

    if not (attrname of glyphspec)
      return

    glyph_value = glyphspec[attrname]
    if _.isString(glyph_value)
      @[attrname].value = glyph_value
    else if _.isObject(glyph_value)
      @[attrname] = _.extend(@[attrname], glyph_value)
    else
      console.log("string property '#{ attrname }' given invalid glyph value: " + glyph_value)

  number: (styleprovider, glyphspec, attrname) ->
    @[attrname] = { typed: true }

    default_value = styleprovider.mget(attrname)
    if not default_value?
    else if _.isNumber(default_value)
      @[attrname].default = default_value
    else
      console.log("number property '#{ attrname }' given invalid default value: " + default_value)

    units_value = styleprovider.mget(attrname+'_units') ? 'data'
    if (attrname+'_units' of glyphspec)
      units_value = glyphspec[attrname+'_units']
    @[attrname].units = units_value

    if not (attrname of glyphspec)
      return

    glyph_value = glyphspec[attrname]
    if _.isString(glyph_value)
      @[attrname].field = glyph_value
    else if _.isNumber(glyph_value)
      @[attrname].value = glyph_value
    else if _.isObject(glyph_value)
      @[attrname] = _.extend(@[attrname], glyph_value)
    else
      console.log("number property '#{ attrname }' given invalid glyph value: " + glyph_value)

  color: (styleprovider, glyphspec, attrname) ->
    @[attrname] = {}

    default_value = styleprovider.mget(attrname)
    if not default_value?
      @[attrname].default = null
    else if _.isString(default_value) and (svg_colors[default_value]? or default_value.substring(0, 1) == "#")
      @[attrname].default = default_value
    else
      console.log("color property '#{ attrname }' given invalid default value: " + default_value)

    if not (attrname of glyphspec)
      return

    glyph_value = glyphspec[attrname]
    if _.isNull(glyph_value)
      @[attrname].value = null
    else if _.isString(glyph_value)
      if svg_colors[glyph_value]? or glyph_value.substring(0, 1) == "#"
        @[attrname].value = glyph_value
      else
        @[attrname].field = glyph_value
    else if _.isObject(glyph_value)
      @[attrname] = _.extend(@[attrname], glyph_value)
    else
      console.log("color property '#{ attrname }' given invalid glyph value: " + glyph_value)
    console.log attrname, @[attrname]

  array: (styleprovider, glyphspec, attrname) ->
    @[attrname] = {}

    default_value = styleprovider.mget(attrname)
    if not default_value?
    else if _.isArray(default_value)
      @[attrname].default = default_value
    else
      console.log("array property '#{ attrname }' given invalid default value: " + default_value)

    units_value = styleprovider.mget(attrname+"_units") ? 'data'
    if (attrname+'_units' of glyphspec)
      units_value = glyphspec[attrname+'_units']
    @[attrname].units = units_value

    if not (attrname of glyphspec)
      return

    glyph_value = glyphspec[attrname]
    if _.isString(glyph_value)
      @[attrname].field = glyph_value
    else if _.isArray(glyph_value)
      @[attrname].value = glyph_value
    else if _.isObject(glyph_value)
      @[attrname] = _.extend(@[attrname], glyph_value)
    else
      console.log("array property '#{ attrname }' given invalid glyph value: " + glyph_value)

  enum: (styleprovider, glyphspec, attrname, vals) ->
    @[attrname] = {}

    levels = vals.split(" ")

    default_value = styleprovider.mget(attrname)
    if _.isNull(default_value)
    else if _.isString(default_value) and default_value in levels
      @[attrname] = {default: default_value}
    else
      console.log("enum property '#{ attrname }' given invalid default value: " + default_value)
      console.log("    acceptable values:" + levels)

    if not (attrname of glyphspec)
      return

    glyph_value = glyphspec[attrname]
    if _.isString(glyph_value)
      if glyph_value in levels
        @[attrname].value = glyph_value
      else
        @[attrname].field = glyph_value
    else if _.isObject(glyph_value)
      @[attrname] = _.extend(@[attrname], glyph_value)
    else
      console.log("enum property '#{ attrname }' given invalid glyph value: " + glyph_value)
      console.log("    acceptable values:" + levels)

  setattr: (styleprovider, glyphspec, attrname, attrtype) ->
    values = null
