Пример #1
0
 def __init__(self, outputFile=None):
     self.__portal = Services.getPortalManager().get(portalId)
     self.__portalManifest = self.__portal.getJsonMap("manifest")
     print formData
     url = formData.get("url")
     if outputFile is None and url is None:
         self.__createPackage()
     elif url is not None and outputFile is not None:
         self.__createPackage(outputFile)
Пример #2
0
 def __createManifest(self):
     manifest = ManifestType()
     meta = MetadataType()
     meta.setSchema("IMS Content")
     meta.setSchemaversion("1.1.4")
     manifest.setMetadata(meta)
     
     portal = Services.getPortalManager().get(portalId)
     portalManifest = portal.getJsonMap("manifest")
     
     orgs = OrganizationsType()
     org = OrganizationType()
     org.setIdentifier("default")
     org.setTitle(portal.getDescription())
     orgs.getOrganization().add(org)
     orgs.setDefault(org)
     manifest.setOrganizations(orgs)
     
     resources = ResourcesType()
     manifest.setResources(resources)
     for key in portalManifest.keySet():
         jsonRes = portalManifest.get(key)
         # item
         visible = jsonRes.get("hidden", "false") != "true"
         item = ItemType()
         item.setIdentifier("default-" + key)
         item.setIdentifierref(key)
         item.setIsvisible(visible)
         item.setTitle(jsonRes.get("title"))
         # webcontent
         webRes = ResourceType()
         webRes.setIdentifier(key)
         webRes.setType("webcontent")
         oid = jsonRes.get("id")
         _, filename = os.path.split(oid)
         baseName = os.path.splitext(filename)[0]
         webRes.setHref("%s/%s.htm" % (key[5:], baseName))
         obj = Services.getStorage().getObject(oid)
         for payload in obj.getPayloadList():
             pid = payload.getId()
             if pid != "SOF-META":
                 file = FileType()
                 file.setHref(pid)
                 webRes.getFile().add(file)
         
         org.getItem().add(item)
         resources.getResource().add(webRes)
     
     return manifest