This is an old revision of the document!


XPCOM

A common problem in developing Mozilla extensions is figuring out how to pass data between different windows, which have their own scopes and do not by default share the same variables and code. While there are various mechanisms to get around this, the recommended method, and the method used by Zotero, is to use an XPCOM singleton component to store common data, which can then be accessed from any window that imports the component. (XPCOM is the cross-platform component object model—the framework—that forms the basis for the Mozilla application environment.)

The base Zotero service is an XPCOM component written in JavaScript. While normally XPCOM components implement various predefined interfaces themselves, in Zotero the data layer and most of the core functionality are stored within a JavaScript object that is then stuffed into the special wrappedJSObject property of the component. The component itself does not define any XPCOM interfaces. (This is vaguely a hack, but it addresses our needs sufficiently and is an approach used by several other extensions.) Chrome overlays and windows in Zotero import the core object via the script include.js, which calls getService() on the component and assigns the wrapped object to the variable Zotero. Zotero methods can then be called from anywhere within the window’s scope simply by calling, for example, var item = Zotero.Items.get(1).

Access to the Zotero service is not limited to Zotero itself, however. As a standard XPCOM component, the Zotero service—and, specifically, the wrapped JavaScript object—can be accessed from anywhere within privileged code, including other loaded extensions. For more, see Interacting with Zotero from Within Firefox.

Central Repository

The site translators that Zotero uses to automatically save information from web pages can stop working correctly as the structure of pages change. If Zotero encounters an error while attempting to scrape a page, it will report the error to the Zotero team so that the translator can be fixed as soon as possible.

Once a day, Zotero checks with the Zotero servers for any translators that have been added or updated and updates its own database with the new translators. This allows the software to remain constantly up-to-date with changing sites and new technologies.

Citation styles can also be updated in this manner.

dev/overview_of_zotero_and_the_technologies_it_uses.1303053358.txt.gz · Last modified: 2011/04/17 11:15 by rmzelle