Ejemplo n.º 1
0
    def call_create_article(self, article=None):
        '''
        Upload a new article.

        :type article: ArticleCreate
        :param article: the article to create

        :return: whether the creation process was successful
        :rtype: bool
        '''

        if not article:
            article = create_article(api=self)

        payload = article.to_json()

        if self.verbose:
            print
            print "--------------------"
            print "Generated json:"
            print
            print payload
            print "--------------------"
            print

        response = self.post(path='/account/articles',
                             payload=payload,
                             headers=get_headers(token=self.token))

        loc = ArticleLocation(**json.loads(response.body_string()))
        return loc
Ejemplo n.º 2
0
    def call_create_article(self, article=None):
        '''
        Upload a new article.

        :type article: ArticleCreate
        :param article: the article to create

        :return: whether the creation process was successful
        :rtype: bool
        '''

        if not article:
            article = create_article(api=self)

        payload = article.to_json()

        if self.verbose:
            print
            print "--------------------"
            print "Generated json:"
            print
            print payload
            print "--------------------"
            print

        response = self.post(path='/account/articles',
                             payload=payload, headers=get_headers(token=self.token))

        loc = ArticleLocation(**json.loads(response.body_string()))
        return loc
Ejemplo n.º 3
0
    def call_create_json(self, model):
        '''
        Creates a json string by interactively asking the user questions about field values.

        :type model: str
        :param model: the model type to create json for (one of: article, collection)
        :return: the initiated model
        :rtype: Model
        '''

        if model == 'article':
            result = create_article(api=self)

        elif model == 'collection':
            result = create_collection(api=self)
        else:
            raise Exception("Model type '{}' not supported".format(model))

        print
        print "Result json for {}:".format(model)
        print
        return result
Ejemplo n.º 4
0
    def call_create_json(self, model):
        '''
        Creates a json string by interactively asking the user questions about field values.

        :type model: str
        :param model: the model type to create json for (one of: article, collection)
        :return: the initiated model
        :rtype: Model
        '''

        if model == 'article':
            result = create_article(api=self)

        elif model == 'collection':
            result = create_collection(api=self)
        else:
            raise Exception("Model type '{}' not supported".format(model))

        print
        print "Result json for {}:".format(model)
        print
        return result