How to Unpickle Komodo’s “xmlc” files

How to Unpickle Komodo's "xmlc" Files

A customer wondered how to get at the state information Komodo saves between sessions. There are three files in saved in the profile directory:
prefs.xml
doc-state.xmlc
view-state.xmlc
The “xmlc” files are pickled XML files, and are essentially unreadable outside Komodo. They’re hard to unpickle outside Komodo, as they contain instances of objects Komodo knows about. But it’s easy to write a macro to do the unpickling:

var dirSvc = Components.classes["@activestate.com/koDirs;1"].getService(Components.interfaces.koIDirs);
var userDataDir = dirSvc.userDataDir;
var osPathSvc = Components.classes["@activestate.com/koOsPath;1"].
getService(Components.interfaces.koIOsPath);
var factory = Components.classes["@activestate.com/koPreferenceSetObjectFactory;1"].
getService();
//

var targetDir = “/tmp/”;

// Would be better to get the list of *.xmlc files where

// there’s no .xml file in place.

var pickledFiles = [‘doc-state.xml’, ‘view-state.xml’];

for (var file, i = 0; file = pickledFiles[i]; i++) {

var fullPath = osPathSvc.join(userDataDir, file);

var targetPath = osPathSvc.join(targetDir, file);

factory.deserializeFile(fullPath).serializeToFile(targetPath);

}



I’ve deliberately had the macro write the plain-text XML files
into a scratch directory, so I can modify the files.
For extra fun, Komodo is flexible when it loads prefs — if it
can’t find a .xmlc file, it will look for a .xml file with
the same root, and load prefs from that instead.
Title photo courtesy of Photo Mix on Pixabay.

Recent Posts

Tech Debt Best Practices: Minimizing Opportunity Cost & Security Risk

Tech debt is an unavoidable consequence of modern application development, leading to security and performance concerns as older open-source codebases become more vulnerable and outdated. Unfortunately, the opportunity cost of an upgrade often means organizations are left to manage growing risk the best they can. But it doesn’t have to be this way.

Read More
Scroll to Top