예제 #1
0
 def createAccount(self, name, siteId, username, password, url, uploadmethod, mediastorageId):
     account = ZBlogAccount(None)
     account.setName(name)
     account.setUsername(username)
     account.setPassword(password)
     if uploadmethod:
         account.setMediaUploadMethod(uploadmethod)
     if mediastorageId:
         account.setMediaUploadStorageId(mediastorageId)
     apiinfo = ZAccountAPIInfo()
     apiinfo.setType(siteId)
     apiinfo.setUrl(url)
     account.setAPIInfo(apiinfo)
     return account
예제 #2
0
 def createAccount(self, name, siteId, username, password, url,
                   uploadmethod, mediastorageId):
     account = ZBlogAccount(None)
     account.setName(name)
     account.setUsername(username)
     account.setPassword(password)
     if uploadmethod:
         account.setMediaUploadMethod(uploadmethod)
     if mediastorageId:
         account.setMediaUploadStorageId(mediastorageId)
     apiinfo = ZAccountAPIInfo()
     apiinfo.setType(siteId)
     apiinfo.setUrl(url)
     account.setAPIInfo(apiinfo)
     return account
예제 #3
0
    def apply(self):
        ZBasePrefsSession.apply(self)

        if KEY_ACCOUNT_USERNAME in self.newSettings:
            self.account.setUsername(self.newSettings[KEY_ACCOUNT_USERNAME])
        if KEY_ACCOUNT_PASSWORD in self.newSettings:
            self.account.setPassword(self.newSettings[KEY_ACCOUNT_PASSWORD])
        if KEY_ACCOUNT_API_URL in self.newSettings:
            apiinfo = ZAccountAPIInfo()
            apiinfo.setType(self.account.getAPIInfo().getType())
            apiinfo.setUrl(self.newSettings[KEY_ACCOUNT_API_URL])
            self.account.setAPIInfo(apiinfo)

        self._getAccountStore().saveAccount(self.account)

        self.newSettings = {}
예제 #4
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