Exemplo n.º 1
0
    def RoundTripNonCollection(self):

        # Export
        repo = self.repos[0]
        theItem = ContentItem(view=repo.view)
        theItem.displayName = "I'm an item"

        conduit = Sharing.FileSystemConduit(sharePath=".",
                                            shareName="exporteditem",
                                            view=repo.view)
        format = Sharing.CloudXMLFormat(view=repo.view)
        self.share3 = Sharing.Share(contents=theItem, conduit=conduit,
                                    format=format, view=repo.view)
        if self.share3.exists():
            self.share3.destroy()
        self.share3.create()
        self.share3.put()

        # Import
        repo = self.repos[1]

        conduit = Sharing.FileSystemConduit(sharePath=".",
                                            shareName="exporteditem",
                                            view=repo.view)
        format = Sharing.CloudXMLFormat(view=repo.view)
        self.share4 = Sharing.Share(conduit=conduit, format=format,
                                    view=repo.view)
        self.share4.get()

        alsoTheItem = self.share4.contents
        self.assert_(alsoTheItem.displayName == "I'm an item",
                     "Single-item import/export failed")
Exemplo n.º 2
0
    def RoundTrip(self):

        # Export
        repo = self.repos[0]
        sandbox = repo.findPath("//sandbox")
        coll = sandbox.findPath("testcollection")

        conduit = Sharing.FileSystemConduit(name="conduit", parent=sandbox,
         sharePath=".", shareName="exportedcollection", view=repo.view)
        format = Sharing.CloudXMLFormat(name="format", parent=sandbox,
                                        view=repo.view)
        self.share1 = Sharing.Share(name="share", parent=sandbox,
                                    contents=coll, conduit=conduit,
                                    format=format, view=repo.view)
        if self.share1.exists():
            self.share1.destroy()
        self.share1.create()
        self.share1.put()

        # Import
        repo = self.repos[1]
        sandbox = repo.findPath("//sandbox")
        coll = sandbox.findPath("testcollection")

        conduit = Sharing.FileSystemConduit(name="conduit", parent=sandbox,
         sharePath=".", shareName="exportedcollection", view=repo.view)
        format = Sharing.CloudXMLFormat(name="format", parent=sandbox,
                                        view=repo.view)
        self.share2 = Sharing.Share(name="share", parent=sandbox,
                                    conduit=conduit, format=format,
                                    view=repo.view)
        self.share2.get()

        # Make sure that the items we imported have the same displayNames
        # as the ones we exported (and no fewer, no more)
        names = {}
        for item in self.share1.contents:
            names[item.displayName] = 1
        for item in self.share2.contents:
            self.assert_(item.displayName in names, "Imported item that wasn't"
             "exported")
            del names[item.displayName]
        self.assert_(len(names) == 0, "Import is missing some items that were"
         "exported")
Exemplo n.º 3
0
    def OnOk(self, evt):
        title = self.textTitle.GetValue()
        shareName = self.textShareName.GetValue()

        accountIndex = self.choiceAccount.GetSelection() - 1
        account = self.accounts[accountIndex]

        if not self.join:
            collIndex = self.choiceColl.GetSelection() - 1
            collection = self.collections[collIndex]

        if self.share is None:
            conduit = Sharing.WebDAVConduit(account=account,
                                            shareName=shareName,
                                            view=self.view)
            if shareName.endswith('.ics'):
                format = ICalendar.ICalendarFormat(view=self.view)
            else:
                format = Sharing.CloudXMLFormat(view=self.view)
            if self.join:
                self.share = Sharing.Share(conduit=conduit,
                                           format=format,
                                           view=self.view)
            else:
                self.share = Sharing.Share(contents=collection,
                                           conduit=conduit,
                                           format=format,
                                           view=self.view)
            self.share.displayName = title
        else:
            self.share.displayName = title
            self.share.conduit.account = account
            self.share.conduit.shareName = shareName
            self.share.contents = collection

        self.EndModal(True)