예제 #1
0
 def createRavenCategoryByName(self, zblogId, categoryName):
     category = ZCategory()
     bogQID = ZQualifiedPublisherId( zblogId)
     urn = u"%s,zoundry:blog:%s" % (bogQID.getLocalId(), bogQID.getServerId())  #$NON-NLS-1$
     qid = ZQualifiedPublisherId(localId=urn, serverId=categoryName)
     category.setId( qid.getId() )
     category.setName(categoryName)
     return category
예제 #2
0
 def _createRavenCategory(self, zblog, serverCategory):
     # Create and return ZCategory object given server side category
     zcategory = ZCategory()
     # copy over server side attribute to raven izblog model
     self._copyAttrsFromServerToRaven(serverCategory, zcategory)
     id = self._createEntryQId( zblog.getId(), serverCategory.getId() )
     zcategory.setId(id)
     zcategory.setName( serverCategory.getName() )
     return zcategory
 def _createRavenCategory(self, zblog, serverCategory):
     # Create and return ZCategory object given server side category
     zcategory = ZCategory()
     # copy over server side attribute to raven izblog model
     self._copyAttrsFromServerToRaven(serverCategory, zcategory)
     id = self._createEntryQId(zblog.getId(), serverCategory.getId())
     zcategory.setId(id)
     zcategory.setName(serverCategory.getName())
     return zcategory
 def createRavenCategoryByName(self, zblogId, categoryName):
     category = ZCategory()
     bogQID = ZQualifiedPublisherId(zblogId)
     urn = u"%s,zoundry:blog:%s" % (
         bogQID.getLocalId(), bogQID.getServerId())  #$NON-NLS-1$
     qid = ZQualifiedPublisherId(localId=urn, serverId=categoryName)
     category.setId(qid.getId())
     category.setName(categoryName)
     return category
예제 #5
0
    def _createAccountFromWLWBlogInfo(self, wlwBlogInfo):
        accountId = generate()
        accountDir = os.path.join(self.accountDir, accountId)
        account = ZWindowsLiveWriterAccount(accountDir)
        account.setId(accountId)
        account.setUsername(wlwBlogInfo.username) 
        (siteName, siteId) = LIVE_WRITER_PROVIDER_MAP[wlwBlogInfo.providerId] #@UnusedVariable
        # Over rides fop WP 2.2
        if wlwBlogInfo.clientType == u"WordPress" and wlwBlogInfo.serviceName == u"WordPress": #$NON-NLS-1$ #$NON-NLS-2$
            siteId = u"zoundry.blogapp.pubsystems.publishers.site.wordpress22" #$NON-NLS-1$
        apiInfo = ZAccountAPIInfo()
        apiInfo.setType(siteId)
        apiInfo.setUrl(wlwBlogInfo.postApiUrl)
        account.setAPIInfo(apiInfo)
        account.setName(wlwBlogInfo.blogName + u" Account") #$NON-NLS-1$

        blog = ZBlogFromAccount()
        blog.setAccount(account)
        blogId = u"{urn:zoundry:acc:%s}%s" % (account.getId(), wlwBlogInfo.blogId) #$NON-NLS-1$
        blog.setId(blogId)
        blog.setName(wlwBlogInfo.blogName)
        blog.setUrl(wlwBlogInfo.homepageUrl)

        # set WLW import attributes
        blog.setAttribute(u"clientType", unicode(wlwBlogInfo.clientType), IZBlogAppNamespaces.WLW_ACCOUNT_NAMESPACE) #$NON-NLS-1$
        blog.setAttribute(u"serviceName", unicode(wlwBlogInfo.serviceName), IZBlogAppNamespaces.WLW_ACCOUNT_NAMESPACE) #$NON-NLS-1$
        blog.setAttribute(u"providerId", unicode(wlwBlogInfo.providerId), IZBlogAppNamespaces.WLW_ACCOUNT_NAMESPACE) #$NON-NLS-1$
        blog.setAttribute(u"fileUploadSupport", unicode(wlwBlogInfo.fileUploadSupport), IZBlogAppNamespaces.WLW_ACCOUNT_NAMESPACE) #$NON-NLS-1$
        if wlwBlogInfo.fileUploadSupport == 2:
            blog.setAttribute(u"ftpServer", unicode(wlwBlogInfo.ftpServer), IZBlogAppNamespaces.WLW_ACCOUNT_NAMESPACE) #$NON-NLS-1$
            blog.setAttribute(u"ftpPath", unicode(wlwBlogInfo.ftpPath), IZBlogAppNamespaces.WLW_ACCOUNT_NAMESPACE) #$NON-NLS-1$
            blog.setAttribute(u"ftpUrl", unicode(wlwBlogInfo.ftpUrl), IZBlogAppNamespaces.WLW_ACCOUNT_NAMESPACE) #$NON-NLS-1$
            blog.setAttribute(u"ftpUsername", unicode(wlwBlogInfo.ftpUsername), IZBlogAppNamespaces.WLW_ACCOUNT_NAMESPACE) #$NON-NLS-1$

        blog.setAttribute(u"id", wlwBlogInfo.blogId, IZBlogAppNamespaces.CMS_PUBLISHER_NAMESPACE) #$NON-NLS-1$
        blog.setAttribute(u"name", unicode(wlwBlogInfo.blogName), IZBlogAppNamespaces.CMS_PUBLISHER_NAMESPACE) #$NON-NLS-1$

        if siteId == DefaultSites.BLOGGER:
            # WLW may have the blogger legacy URL. Use the new url for api
            apiInfo.setUrl(u"http://www.blogger.com/feeds/default/blogs") #$NON-NLS-1$
            linkBase = wlwBlogInfo.homepageUrl
            if not linkBase.endswith(u"/"): #$NON-NLS-1$
                linkBase = linkBase + u"/" #$NON-NLS-1$
            feedLink = linkBase + u"feeds/posts/default" #$NON-NLS-1$
            altLink = wlwBlogInfo.homepageUrl
            postLink = wlwBlogInfo.postApiUrl
            catsLink = feedLink
            feedTitle = wlwBlogInfo.blogName
            atomId = wlwBlogInfo.blogId
            blog.setAttribute(u"feed-link", feedLink, IZBlogAppNamespaces.ATOM_PUBLISHER_NAMESPACE) #$NON-NLS-1$
            blog.setAttribute(u"alt-link", altLink, IZBlogAppNamespaces.ATOM_PUBLISHER_NAMESPACE) #$NON-NLS-1$
            blog.setAttribute(u"post-link", postLink, IZBlogAppNamespaces.ATOM_PUBLISHER_NAMESPACE) #$NON-NLS-1$
            blog.setAttribute(u"categories-link", catsLink, IZBlogAppNamespaces.ATOM_PUBLISHER_NAMESPACE) #$NON-NLS-1$
            blog.setAttribute(u"feed-title", feedTitle, IZBlogAppNamespaces.ATOM_PUBLISHER_NAMESPACE) #$NON-NLS-1$
            blog.setAttribute(u"id", atomId, IZBlogAppNamespaces.ATOM_PUBLISHER_NAMESPACE) #$NON-NLS-1$

        for (catId, catName) in wlwBlogInfo.categories:
            category = ZCategory()
            category.setId(catId)
            category.setName(catName)
            blog.addCategory(category)

        account.addBlog(blog)
        # CANNOT CREATE MEDIA STORES HERE: as it needs mediastore service - which is not started until after
        # profile has started (i.e. after profile manager)
        # This part of the code needs to be run after the app has started.

        return account
예제 #6
0
 def _deserializeCategory(self, categoryNode, blogInfo):
     category = ZCategory()
     self._deserializeAttributes(categoryNode, category)
     blogInfo.addCategory(category)
예제 #7
0
    def _deserializeBlogCategory(self, categoryNode, blog):
        category = ZCategory()

        self._deserializeAttributes(categoryNode, category)

        blog.addCategory(category)