def convert(self, data, outdata, **kwargs): """Input is a content folderish object. Output is idata, but getData returns a binary zip file.""" # construct manifest file structure obj = data.getPublishedObject() if not obj: obj = data # this needs to be smarter for non-pub objects identity = IDENTIFIER % obj.absolute_url() manifestzpt = PageTemplateFile('www/ieeemd', GLOBALS) manifestzpt.content_type = "text/xml" manifestzpt.title = "Manifest Template" manifestzpt = manifestzpt.__of__(data) # set up metadata info modmeta = data.getMetadata() moduledata = {} moduledata["modulename"] = data.getId() moduledata["url"] = (data.getPublishedObject() or data).absolute_url() moduledata["title"] = modmeta['title'] moduledata["description"] = modmeta['abstract'] owners = () for x in modmeta['licensors']: owners = owners + (getUserFullname(data, x),) moduledata["rights"] = "This module is copyright %s under the license: %s" % (", ".join(owners), modmeta['license']) moduledata["size"] = data.get_size() moduledata["mime"] = "application/cnxml+xml" moduledata["language"] = 'en' #moduledata["userlanguage"] = 'en' moduledata["keywords"] = modmeta['keywords'] moduledata["version"] = modmeta['version'] moduledata["status"] = data.state in ("created", "modified") and "draft" or "final" contributors = () for x in modmeta['authors']: vcard = getUserVCard(data, x) contributors = contributors + ({"role":"author", "entity":vcard},) # also date, but we don't support that for x in modmeta['maintainers']: vcard = getUserVCard(data, x) contributors = contributors + ({"role":"editor", "entity":vcard},) # also date, but we don't support that moduledata["contributors"] = contributors #moduledata["interactive"] = 0 # how do we figure this? # future: references (links), annotations, classifications (taxonomy) moduledata["files"] = [] def addToResource(name, path, obj): moduledata["files"].append(path) container = data.getId().replace('.','-') content, zipfile = makeZipFile(data, container, callback=addToResource) ## disable XHTML export until we have a better handle on what it looks like #source = data.module_export_template(**kw) #text = data.cnxml_transform(source, stylesheet=MODULE_XSL) #zipfile.writestr('%s/index.xhtml' % container, text) manifest = manifestzpt(**moduledata) zipfile.writestr(MANIFEST, manifest) zipfile.close() outdata.setData(content.getvalue()) content.close() # nothing to do for outdata.setSubObjects(objects) return outdata