コード例 #1
0
ファイル: mediastoragedefs.py プロジェクト: mpm2050/Raven
 def getDisplayName(self):
     displayName = self._getExtensionText(
         u"plg:media-site/plg:display-name")  #$NON-NLS-1$
     if not displayName:
         raise ZBlogAppException(
             u"Missing required meta data: 'display-name'")  #$NON-NLS-1$
     return displayName
コード例 #2
0
ファイル: raven.py プロジェクト: mpm2050/Raven
    def _createUserProfile(self):
        from zoundry.blogapp.ui.profile.manager import ZUserProfileManager

        profile = None
        profileModel = ZProfileManagerModel()

        # Choose a profile, either by popping up the dialog, by taking the
        # default, or by honoring the command line param.
        if profileModel.isCommandLineSpecified():
            profile = profileModel.getCommandLineProfile()
        if profileModel.isBypassDialog():
            defaultProfileName = profileModel.getDefaultProfileName()
            profile = profileModel.getProfile(defaultProfileName)

        # Pop up the user profile manager (allows for creating new profiles and choosing a profile to use).
        if not profile:
            rvalMap = {}
            userProfileApp = wx.PySimpleApp()
            ZUserProfileManager(rvalMap, profileModel, self.systemProfile)
            userProfileApp.MainLoop()
            # If nothing set, then cancel was hit and we should just return.
            if not rvalMap.has_key(u"user-profile-name"):  #$NON-NLS-1$
                return
            profileName = rvalMap[u"user-profile-name"]  #$NON-NLS-1$
            profile = profileModel.getProfile(profileName)

        if not profile:
            raise ZBlogAppException(
                _extstr(u"raven.ErrorFindingProfile"))  #$NON-NLS-1$

        factory = ZUserProfileFactory()
        return factory.createUserProfile(USER_PROFILE_TYPE_FILE,
                                         profile.getPath())  #$NON-NLS-1$
コード例 #3
0
ファイル: factory.py プロジェクト: mpm2050/Raven
 def getSerializer(self, namespace=RAVEN_BLOG_ACCOUNT_NAMESPACE):
     if namespace in self.serializerMap:
         return self.serializerMap[namespace]
     else:
         raise ZBlogAppException(
             _extstr(u"factory.NoSerializerForAccountError") %
             namespace)  #$NON-NLS-1$
コード例 #4
0
ファイル: factory.py プロジェクト: mpm2050/Raven
 def getDeserializer(self, namespace):
     if namespace in self.deserializerMap:
         return self.deserializerMap[namespace]
     else:
         raise ZBlogAppException(
             _extstr(u"factory.NoAccountDeserializer") %
             namespace)  #$NON-NLS-1$
コード例 #5
0
ファイル: templateio.py プロジェクト: mpm2050/Raven
def saveTemplate(template):
    try:
        serializer = getTemplateSerializerFactory().getSerializer()
        serializer.serialize(template)
    except Exception, e:
        getLoggerService().exception(e)
        raise ZBlogAppException(u"Failed to save template: %s" %
                                template.getDirectoryPath(), e)  #$NON-NLS-1$
コード例 #6
0
ファイル: mediasiteimpl.py プロジェクト: mpm2050/Raven
 def _overrideProperty(self, property):
     for prop in self.properties:
         if prop.getName() == property.getName():
             prop.override(property)
             return
     raise ZBlogAppException(
         _extstr(u"mediasiteimpl.InvalidPropertyOverride") %
         property.getName())  #$NON-NLS-1$
コード例 #7
0
ファイル: factory.py プロジェクト: mpm2050/Raven
 def getSerializer(self,
                   namespace=IZDocumentSerializationConstants.
                   RAVEN_BLOG_DOCUMENT_NAMESPACE):
     if namespace in self.serializerMap:
         return self.serializerMap[namespace]
     else:
         raise ZBlogAppException(u"No serializer found for '%s'." %
                                 namespace)  #$NON-NLS-1$
コード例 #8
0
def saveAccount(account):
    try:
        serializer = getAccountSerializerFactory().getSerializer()
        serializer.serialize(account)
    except Exception, e:
        raise ZBlogAppException(
            _extstr(u"accountio.FailedToSaveAccount") %
            account.getDirectoryPath(), e)  #$NON-NLS-1$
コード例 #9
0
ファイル: mediastoragedefs.py プロジェクト: mpm2050/Raven
 def getMediaStorageTypeId(self):
     mstId = self._getExtensionText(
         u"plg:media-site/plg:media-storage-type-id")  #$NON-NLS-1$
     if not mstId:
         raise ZBlogAppException(
             u"Missing required meta data: 'media-storage-type-id'"
         )  #$NON-NLS-1$
     return mstId
コード例 #10
0
def saveMediaStorage(storage, storeXmlPath):
    try:
        serializer = getMediaStorageSerializerFactory().getSerializer()
        dom = serializer.serialize(storage)
        dom.save(storeXmlPath, True)
    except Exception, e:
        raise ZBlogAppException(
            _extstr(u"mediastorageio.FailedToSaveStore") % storage.getId(),
            e)  #$NON-NLS-1$
コード例 #11
0
ファイル: indeximpl.py プロジェクト: mpm2050/Raven
    def _getSinglePubData(self):
        # If there are no pub datas, return an empty one.
        if not self._hasPubData():
            return IZPubDataIDO()
        # If there is exactly one pub data, return it.
        if len(self.pubDataIDOs) == 1:
            return self.pubDataIDOs[0]

        raise ZBlogAppException(u"Illegal attempt to treat a IZDocumentIDO as a reference to a single published Document (multiple pubData objects found).") #$NON-NLS-1$
コード例 #12
0
 def _createMediaStorage(self, name, mediaSiteId, properties):
     site = self.getMediaSite(mediaSiteId)
     if site is None:
         raise ZBlogAppException(_extstr(u"mediastoragesrvc.NoMediaSiteFound") % mediaSiteId) #$NON-NLS-1$
     id = generate()
     storageTypeId = site.getMediaStorageTypeId()
     storageType = self._getMediaStorageType(storageTypeId)
     storage = ZMediaStorage(id, name, mediaSiteId, properties)
     registryFile = os.path.join(self.mediaStoresDirectory, id + u".store.registry") #$NON-NLS-1$
     storage.init(site, storageType, registryFile)
     return storage
コード例 #13
0
 def createMediaStorage(self, name, mediaSiteId, properties, persist = True):
     if self.hasMediaStorage(name):
         raise ZBlogAppException(_extstr(u"mediastoragesrvc.FailedToAddMediaStorageError") % name) #$NON-NLS-1$
     storage = self._createMediaStorage(name, mediaSiteId, properties)
     if persist:
         self.mediaStores.append(storage)
         self.saveMediaStorage(storage)
         self.logger.debug(u"Created a media storage named '%s' using site '%s'." % (name, mediaSiteId)) #$NON-NLS-1$
         for listener in self.listeners:
             listener.onMediaStorageAdded(storage)
     return storage
コード例 #14
0
ファイル: dataio.py プロジェクト: mpm2050/Raven
def saveDocument(document, documentXmlPath):
    try:
        dataDir = os.path.dirname(documentXmlPath)
        context = ZBlogDocumentSerializationContext(dataDir)
        serializer = getDocumentSerializerFactory().getSerializer()
        dom = serializer.serialize(document, context)
        dom.save(documentXmlPath, True)
    except Exception, e:
        raise ZBlogAppException(
            _extstr(u"dataio.FailedToSaveDocument") % documentXmlPath,
            e)  #$NON-NLS-1$
コード例 #15
0
ファイル: appwindow.py プロジェクト: mpm2050/Raven
 def _createPerspective(self, perspectiveId):
     pdef = self._getPerspectiveDef(perspectiveId)
     if not pdef:
         pdef = self._getPerspectiveDef(PERSPECTIVE_DEFAULT)
     if not pdef:
         raise ZBlogAppException(
             _extstr(
                 u"appwindow.FailedToLoadDefaultPerspective"))  #$NON-NLS-1$
     pclass = pdef.getClass()
     perspective = pclass()
     return perspective
コード例 #16
0
def loadMediaStorage(mediaStoreXmlPath):
    try:
        dom = ZDom()
        dom.load(mediaStoreXmlPath)

        deserializer = getMediaStorageDeserializerFactory().getDeserializer(
            dom.documentElement.getNamespaceUri())
        return deserializer.deserialize(dom)
    except Exception, e:
        raise ZBlogAppException(_extstr(u"mediastorageio.FailedToLoadStore"),
                                e)  #$NON-NLS-1$
コード例 #17
0
def loadStaticHtml(path, params=None):
    if not os.path.isfile(path):
        raise ZBlogAppException(
            _extstr(u"viewutil.HtmlFileNotFoundError") % path)  #$NON-NLS-1$

    f = open(path, u"rb")  #$NON-NLS-1$
    html = f.read()
    f.close()

    rval = convertToUnicode(html)
    if params:
        rval = rval % params
    return rval
コード例 #18
0
ファイル: templateio.py プロジェクト: mpm2050/Raven
def loadTemplate(templateDir):
    try:
        templateXmlPath = os.path.join(templateDir,
                                       u"template.xml")  #$NON-NLS-1$
        dom = ZDom()
        dom.load(templateXmlPath)

        deserializer = getTemplateDeserializerFactory().getDeserializer(
            dom.documentElement.getNamespaceUri())
        return deserializer.deserialize(templateDir, dom)
    except Exception, e:
        raise ZBlogAppException(u"Failed to load template: %s" % templateDir,
                                e)  #$NON-NLS-1$
コード例 #19
0
def loadAccount(accountDir):
    try:
        accountXmlPath = os.path.join(accountDir, u"account.xml")  #$NON-NLS-1$
        dom = ZDom()
        dom.load(accountXmlPath)

        deserializer = getAccountDeserializerFactory().getDeserializer(
            dom.documentElement.getNamespaceUri())
        return deserializer.deserialize(accountDir, dom)
    except Exception, e:
        raise ZBlogAppException(
            _extstr(u"accountio.FailedToLoadAccount") % accountDir,
            e)  #$NON-NLS-1$
コード例 #20
0
ファイル: manager.py プロジェクト: mpm2050/Raven
    def deleteProfile(self, profileName, deleteContent=False):
        profileElem = self.profilesDom.selectSingleNode(
            u"/profiles/profile[@name = \"%s\"]" % profileName)  #$NON-NLS-1$
        if not profileElem:
            raise ZBlogAppException(
                _extstr(u"manager.ProfileNotFound") %
                profileName)  #$NON-NLS-1$

        # Now delete the content...
        if deleteContent:
            path = profileElem.getText()
            fileutil.deleteDirectory(path, True)
        profileElem.parentNode.removeChild(profileElem)
        self._saveProfilesDom()
コード例 #21
0
ファイル: dataio.py プロジェクト: mpm2050/Raven
def loadDocument(documentXmlPath):
    try:
        dom = ZDom()
        dom.load(documentXmlPath)

        dataDir = os.path.dirname(documentXmlPath)
        context = ZBlogDocumentSerializationContext(dataDir)
        deserializer = getDocumentDeserializerFactory().getDeserializer(
            dom.documentElement.getNamespaceUri())
        return deserializer.deserialize(dom, context)
    except Exception, e:
        raise ZBlogAppException(
            _extstr(u"dataio.DocumentLoadFailedError") % documentXmlPath,
            e)  #$NON-NLS-1$
コード例 #22
0
    def start(self, applicationModel):
        self.applicationModel = applicationModel
        self.logger = applicationModel.getEngine().getService(IZAppServiceIDs.LOGGER_SERVICE_ID)
        self.mediaStoresDirectory = self._getMediaStoragesDirectory()
        self.mediaStoreTypes = self._loadMediaStorageTypes()
        self.mediaSites = self._loadMediaSites()
        self.mediaStores = self._loadMediaStorages()

        for site in self.mediaSites:
            mediaStoreTypeId = site.getMediaStorageTypeId()
            mediaStoreType = self._getMediaStorageType(mediaStoreTypeId)
            if mediaStoreType is None:
                raise ZBlogAppException(_extstr(u"mediastoragesrvc.StoreTypeNotFoundError") % (site.getId(), mediaStoreTypeId)) #$NON-NLS-1$
            site.setMediaStorageType(mediaStoreType)

        self.logger.debug(u"Media Storage Service started [%d types, %d sites, %d storages loaded]." % (len(self.mediaStoreTypes), len(self.mediaSites), len(self.mediaStores))) #$NON-NLS-1$
コード例 #23
0
 def uploadFile(self, fileName, fullPath, listener, metaData):
     u"""Implements the method to adapt the file to a stream and delegate to
     _uploadStream(filename, fileStream) method.
     """  #$NON-NLS-1$
     try:
         file = open(fullPath, u"rb")  #$NON-NLS-1$
         stream = ZStreamWrapper(
             file, ZStreamToUploadListenerAdapter(listener, fileName))
         try:
             return self._uploadStream(fileName, stream, metaData)
         finally:
             stream.close()
     except Exception, e:
         # FIXME (PJ) used key prefix mediastorageprovider
         raise ZBlogAppException(
             _extstr(u"mediastorageimpl.FailedToUploadFile") % fileName,
             e)  #$NON-NLS-1$
コード例 #24
0
    def _loadMediaStorages(self):
        storages = []

        storageFiles = getDirectoryListing(self.mediaStoresDirectory, STORE_FILE_FILTER)
        for storageFile in storageFiles:
            registryFile = storageFile + u".registry" #$NON-NLS-1$
            storage = self._loadMediaStorage(storageFile)
            mediaSiteId = storage.getMediaSiteId()
            site = self.getMediaSite(mediaSiteId)
            if site is None:
                raise ZBlogAppException(_extstr(u"mediastoragesrvc.NoMediaSiteFound") % mediaSiteId) #$NON-NLS-1$
            storageTypeId = site.getMediaStorageTypeId()
            storageType = self._getMediaStorageType(storageTypeId)
            storage.init(site, storageType, registryFile)
            storages.append(storage)

        return storages
コード例 #25
0
ファイル: raven.py プロジェクト: mpm2050/Raven
    def run(self):
        from zoundry.blogapp.startup import RavenApplicationStartup
        from zoundry.blogapp.ui.appwindow import ZRavenApplicationWindow
        from zoundry.blogapp.ui.splash import ZStartupWindow

        client = ZRavenRPCClient()

        # First, check for blogThis
        blogThisInfo = checkCmdLineForBlogThis()
        if blogThisInfo is not None:
            client.blogThis(blogThisInfo)

        # Only allow one instance of the application to be running.
        if client.getVersion() is not None:
            client.bringToFront()
            return

        # Create the user profile (return if none is found/chosen)
        userProfile = self._createUserProfile()
        if not userProfile:
            return
        self.applicationModel.setUserProfile(userProfile)

        # set http proxy settings based on userprofile config
        self._initProxyConfiguration()

        # Startup the Engine (load plugins, etc...)
        splashApp = wx.PySimpleApp()
        try:
            splashWindow = ZStartupWindow()
            appStartup = RavenApplicationStartup(self.applicationModel,
                                                 splashWindow)
            appStartup.start()
            splashApp.MainLoop()

            if appStartup.hasStartupErrors():
                raise ZBlogAppException(
                    _extstr(u"raven.StartupErrorsFoundMsg"))  #$NON-NLS-1$
        except Exception, e:
            ZShowExceptionMessage(None, e)
コード例 #26
0
    def _deserializeContent(self, documentDom, document,
                            deserializationContext):
        contentNode = documentDom.selectSingleNode(
            u"/zns:entry/zns:content")  #$NON-NLS-1$

        # Handle the Case of the Missing Content
        if not contentNode:
            xhtmlDoc = loadXhtmlDocumentFromString(u"")  #$NON-NLS-1$
            content = ZXhtmlContent()
            content.setMode(u"xml")  #$NON-NLS-1$
            content.setType(u"application/xhtml+xml")  #$NON-NLS-1$
            content.setXhtmlDocument(xhtmlDoc)
            document.setContent(content)
            return

        self._processContent(contentNode, deserializationContext)

        mode = contentNode.getAttribute(u"mode")  #$NON-NLS-1$
        type = contentNode.getAttribute(u"type")  #$NON-NLS-1$

        content = ZXhtmlContent()
        content.setMode(mode)
        content.setType(type)

        if mode == u"xml":  #$NON-NLS-1$
            xhtmlNode = contentNode.selectSingleNode(u"*")  #$NON-NLS-1$
            xhtmlDoc = loadXhtmlDocumentFromDOM(xhtmlNode)
            content.setXhtmlDocument(xhtmlDoc)
        elif mode == u"escaped":  #$NON-NLS-1$
            htmlText = contentNode.getText()
            xhtmlDoc = loadXhtmlDocumentFromString(htmlText)
            content.setXhtmlDocument(xhtmlDoc)
        else:
            raise ZBlogAppException(
                _extstr(
                    u"deserializers.NoContentModeFoundError"))  #$NON-NLS-1$

        document.setContent(content)
コード例 #27
0
ファイル: manager.py プロジェクト: mpm2050/Raven
    def createProfile(self, profileInfo):
        (name, path) = profileInfo
        fullPath = path

        # if running in portable mode, the path needs to be stored
        # relative to the profiles.xml file.
        if isPortableEnabled():
            profileDirPath = self.getDefaultProfilesDirectory()
            path = makeRelativePath(profileDirPath, fullPath)

        # Check if we have one with the same name already.
        if self.getProfile(name) is not None:
            raise ZBlogAppException(
                _extstr(u"manager.ProfileAlreadyExists") % name)  #$NON-NLS-1$

        profileElem = self.profilesDom.createElement(u"profile")  #$NON-NLS-1$
        profileElem.setAttribute(u"name", name)  #$NON-NLS-1$
        profileElem.setText(path)
        self.profilesDom.documentElement.appendChild(profileElem)
        self._saveProfilesDom()

        if not os.path.exists(fullPath):
            os.makedirs(fullPath)
コード例 #28
0
ファイル: factory.py プロジェクト: mpm2050/Raven
 def getSerializer(self, namespace = RAVEN_MEDIASTORE_NAMESPACE_VER1):
     if namespace in self.serializerMap:
         return self.serializerMap[namespace]
     else:
         raise ZBlogAppException(u"No serializer found for '%s'." % namespace) #$NON-NLS-1$
コード例 #29
0
ファイル: factory.py プロジェクト: mpm2050/Raven
 def getDeserializer(self, namespace):
     if namespace in self.deserializerMap:
         return self.deserializerMap[namespace]
     else:
         raise ZBlogAppException(u"No deserializer found for '%s'." % namespace) #$NON-NLS-1$
コード例 #30
0
ファイル: importer.py プロジェクト: mpm2050/Raven
 def addListener(self, listener):
     if not isinstance(listener, IZRunnableProgressListener):
         raise ZBlogAppException(
             _extstr(u"importer.IncorrectListenerType"))  #$NON-NLS-1$
     self.listeners.append(listener)