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

        email = self.request.get("email", None)
        password = self.request.get("password", None)
        if not email or not password:
            logging.error("Missing email or password")
            self.redirect("/auth/admin/new?failure=missing")
            return

        token = None
        try:
            ning_client = config.new_client()
            token = ning_client.login(email, password)
        except NingError, e:
            logging.error("Unable to get token: %s" % str(e))
            self.redirect("/auth/admin/new?failure=%s-%s" % (e.error_code, e.error_subcode))
            return
Exemplo n.º 2
0
    def post(self):

        email = self.request.get("email", None)
        password = self.request.get("password", None)
        if not email or not password:
            logging.error("Missing email or password")
            self.redirect("/auth/admin/new?failure=missing")
            return

        token = None
        try:
            ning_client = config.new_client()
            token = ning_client.login(email, password)
        except NingError, e:
            logging.error("Unable to get token: %s" % str(e))
            self.redirect("/auth/admin/new?failure=%s-%s" % (e.error_code,
                e.error_subcode))
            return
Exemplo n.º 3
0
    def post(self):
        """Publish the given blog post to the configured Ning Network"""

        entry_key = self.request.get("entry_key", None)
        if not entry_key:
            logging.warn("No entry_key provided")
            return

        entry = ContentEntry.get(entry_key)
        if not entry:
            logging.warn("Entry not found in the DB: %s" % entry_key)
            return

        entry.retry_count += 1
        entry.put()

        logging.debug("Dequeued entry: \"%s\" %s" % (entry.title,
            entry.pub_date.ctime()))

        credentials = Credential.all().filter("owner =", entry.owner).get()
        if not credentials:
            logging.warn("No credentials found for %s, deleting" % entry.owner)
            entry.delete()
            return


        blog_parts = {
            "title": entry.title.encode("utf-8"),
            "description": entry.description.encode("utf-8"),
            "canonicalUrl": entry.link.encode("utf-8"),
            # "publishTime": unicode(publish_time.isoformat()).encode("utf-8")
        }

        token = oauth.Token(key=credentials.token_key,
            secret=credentials.token_secret)
        ning_client = config.new_client(token)

        try:
            response = ning_client.post("BlogPost", blog_parts)
        except NingError, e:
            logging.error("Unable to upload: %s" % str(e))
            return
Exemplo n.º 4
0
    def post(self):
        """Publish the given blog post to the configured Ning Network"""

        entry_key = self.request.get("entry_key", None)
        if not entry_key:
            logging.warn("No entry_key provided")
            return

        entry = ContentEntry.get(entry_key)
        if not entry:
            logging.warn("Entry not found in the DB: %s" % entry_key)
            return

        entry.retry_count += 1
        entry.put()

        logging.debug("Dequeued entry: \"%s\" %s" %
                      (entry.title, entry.pub_date.ctime()))

        credentials = Credential.all().filter("owner =", entry.owner).get()
        if not credentials:
            logging.warn("No credentials found for %s, deleting" % entry.owner)
            entry.delete()
            return

        blog_parts = {
            "title": entry.title.encode("utf-8"),
            "description": entry.description.encode("utf-8"),
            "canonicalUrl": entry.link.encode("utf-8"),
            # "publishTime": unicode(publish_time.isoformat()).encode("utf-8")
        }

        token = oauth.Token(key=credentials.token_key,
                            secret=credentials.token_secret)
        ning_client = config.new_client(token)

        try:
            response = ning_client.post("BlogPost", blog_parts)
        except NingError, e:
            logging.error("Unable to upload: %s" % str(e))
            return