Monday, November 08, 2010 at 12:04 AM.


on getODBMimeType (adr) { //get the MIME type of a database object
	<<Cache mime types, so we only do the lookup once per file.
	local (adrCache = @system.temp.mainResponder.mimeTypeCache);
	if not defined (adrCache^) {
		new (tableType, adrCache)}
	else {
		try {return (adrCache^.[adr])}}; //the mime type may be cached
	local (mimeType = "text/html");
	local (objectType = typeOf (adr^));
	if objectType == binaryType {
		objectType = getBinaryType (adr^)};
	try {mimeType = user.webserver.prefs.type2MIME.[objectType]};
	adrCache^.[adr] = mimeType; //cache the mime type
	return (mimeType)}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.