code: function(obj) {
          var context = {};
          var layers = obj.layers;
          if (obj.CLASS_NAME == "OpenLayers.Map") {
              var metadata = obj.metadata || {};
              context.size = obj.getSize();
              context.bounds = obj.getExtent();
              context.projection = obj.projection;
              context.title = obj.title;
              context.keywords = metadata.keywords;
              context["abstract"] = metadata["abstract"];
              context.logo = metadata.logo;
              context.descriptionURL = metadata.descriptionURL;
              context.contactInformation = metadata.contactInformation;
              context.maxExtent = obj.maxExtent;
          } else {
              // copy all obj properties except the "layers" property
              OpenLayers.Util.applyDefaults(context, obj);
              if (context.layers != undefined) {
                  delete(context.layers);
              }
          }
  
          if (context.layersContext == undefined) {
              context.layersContext = [];
          }
  
          // let's convert layers into layersContext object (if any)
          if (layers != undefined && OpenLayers.Util.isArray(layers)) {
              for (var i=0, len=layers.length; i<len; i++) {
                  var layer = layers[i];
                  if (layer instanceof OpenLayers.Layer.WMS) {
                      context.layersContext.push(this.layerToContext(layer));
                  }
              }
          }
          return context;
      }
docs: Method: toContext
  Create a context object free from layer given a map or a
  context object.
  
  Parameters:
  obj - {<OpenLayers.Map> | Object} The map or context.
  
  Returns:
  {Object} A context object.