function __construct($view, $moduleName)
 {
     // BEGIN ASSERTIONS
     if (!isset($this->_fileVariables[$view])) {
         sugar_die(get_class($this) . ": View {$view} is not supported");
     }
     if (!isset($GLOBALS['beanList'][$moduleName])) {
         sugar_die(get_class($this) . ": Modulename {$moduleName} is not a Deployed Module");
     }
     // END ASSERTIONS
     $this->_view = strtolower($view);
     $this->_moduleName = $moduleName;
     $module = new StudioModule($moduleName);
     $fielddefs = $module->getFields();
     $loaded = null;
     foreach (array(MB_BASEMETADATALOCATION, MB_CUSTOMMETADATALOCATION, MB_WORKINGMETADATALOCATION, MB_HISTORYMETADATALOCATION) as $type) {
         $this->_sourceFilename = $this->getFileName($view, $moduleName, $type);
         if (null !== ($layout = $this->_loadFromFile($this->_sourceFilename))) {
             // merge in the fielddefs from this layout
             $this->_mergeFielddefs($fielddefs, $layout);
             $loaded = $layout;
         }
     }
     if ($loaded === null) {
         switch ($view) {
             case MB_QUICKCREATE:
                 // Special handling for QuickCreates - if we don't have a QuickCreate definition in the usual places, then use an EditView
                 $loaded = $this->_loadFromFile($this->getFileName(MB_EDITVIEW, $this->_moduleName, MB_BASEMETADATALOCATION));
                 if ($loaded === null) {
                     throw new Exception(get_class($this) . ": cannot convert from EditView to QuickCreate for Module {$this->_moduleName} - definitions for EditView are missing");
                 }
                 // Now change the array index
                 $temp = $loaded[GridLayoutMetaDataParser::$variableMap[MB_EDITVIEW]];
                 unset($loaded[GridLayoutMetaDataParser::$variableMap[MB_EDITVIEW]]);
                 $loaded[GridLayoutMetaDataParser::$variableMap[MB_QUICKCREATE]] = $temp;
                 // finally, save out our new definition so that we have a base record for the history to work from
                 $this->_sourceFilename = self::getFileName(MB_QUICKCREATE, $this->_moduleName, MB_CUSTOMMETADATALOCATION);
                 $this->_saveToFile($this->_sourceFilename, $loaded);
                 $this->_mergeFielddefs($fielddefs, $loaded);
                 break;
             default:
         }
         if ($loaded === null) {
             throw new Exception(get_class($this) . ": view definitions for View {$this->_view} and Module {$this->_moduleName} are missing");
         }
     }
     $this->_viewdefs = $loaded;
     // Set the original Viewdefs - required to ensure we don't lose fields from the base layout
     // Check the base location first, then if nothing is there (which for example, will be the case for some QuickCreates, and some mobile layouts - see above)
     // we need to check the custom location where the derived layouts will be
     foreach (array(MB_BASEMETADATALOCATION, MB_CUSTOMMETADATALOCATION) as $type) {
         $sourceFilename = $this->getFileName($view, $moduleName, $type);
         if (null !== ($layout = $this->_loadFromFile($sourceFilename))) {
             $this->_originalViewdefs = $layout;
             break;
         }
     }
     $this->_fielddefs = $fielddefs;
     $this->_history = new History($this->getFileName($view, $moduleName, MB_HISTORYMETADATALOCATION));
 }