Logo Search packages:      
Sourcecode: pythoncard version File versions  Download package

def textRouter::TextRouter::on_menuBloggerDeletePost_select (   self,
  event 
)

Deletes a post.

Definition at line 1490 of file textRouter.py.

01490                                                     :
        """Deletes a post."""
        if not self.checkBloggerAccounts(3):
            return

        curBlogAccount = self.theBloggerAccounts[self.theCurrentBloggerAccount]

        # check logged in
        if (not curBlogAccount.checkSetupOK(15)):
            self.status(curBlogAccount.getErrorMessage())
            return 0


        if "previousPosts" not in curBlogAccount.blogs[curBlogAccount.prefs["activeBlog"]-1] or \
               curBlogAccount.blogs[curBlogAccount.prefs["activeBlog"]-1]["previousPosts"] == []:
            self.showWaitMsg("Fetching previous posts...")

            postid = curBlogAccount.bloggerFetchPreviousPosts()
            if curBlogAccount.anErrorOccured():
                self.status(curBlogAccount.getErrorMessage())
                return
            else:
                self.status("Previous posts fetched, now choose one to delete...")

        #if (not curBlogAccount.checkSetupOK(8)):
            #self.status(curBlogAccount.getErrorMessage())
            #return
        
        
        activeBlogIndex = curBlogAccount.prefs["activeBlog"]-1
        prevPosts = curBlogAccount.blogs[activeBlogIndex]["previousPosts"]

        options = []
        for index in range(len(prevPosts)):
            text = prevPosts[index]["content"].replace("\n"," ")
            options.append( "%d: %s%s" % (index+1, text[0:50], (len(text) > 50) and "..." or "") )

        default = options[0]
        dlg = ChooserDialog(self, 'Choose Post To Delete', \
                            "Choose the post to delete...", \
                            options, default)
        dlg.showModal()
        
        if not dlg.accepted():
            self.status("Post deletion cancelled.")
        else:
            i = dlg.components.options.findString(dlg.components.options.stringSelection)
            if i == -1:
                self.status("No previous post selected for deletion.")
            else:
                self.showWaitMsg("Deleting...")

                postid = prevPosts[i]["postid"]
                curBlogAccount.bloggerDeletePost(i)
                
                if curBlogAccount.anErrorOccured():
                    self.status(curBlogAccount.getErrorMessage())
                else:
                    self.status("Post deleted successfully.")
                    if curBlogAccount.currentPostId == postid:
                        curBlogAccount.currentPostId = -1
                    
        dlg.destroy()


    def on_menuBloggerUpdatePost_select(self, event):


Generated by  Doxygen 1.6.0   Back to index