Exemple #1
0
def getFilename (id):
    '''
    >>> getFilename("1207262047") #doctest: +ELLIPSIS
    '/home/.../1207262047.muse'
    '''
    article = Article()
    return article._path(id)
Exemple #2
0
def updateArticle(doc_id):
    """
    We use when an article is written/modified. It also update index. To
    use the function we need the muse file for index, the html file for
    article.
    >>> ma = MuseArticle('1201170413')    
    >>> #ma.html
    >>> #updateArticle('1201170413')
    """
    mu = MuseArticle(doc_id)
    index = mu.json
    html = mu.html
    files = mu.files

    # We have to update the index file both side client and server.
    # Because some functions of the client side requires index file such
    # as the function getUnupdatedArticles. That function is used to check
    # the articles that unpublished.

    # Client side only need index. The html created from emacs.
    article = Article()
    article.set(doc_id)
    article.updateFromDict(index)
    articles = Articles()
    articles.set()
    articles.updateFromObj(article)
    articles.save()

    # Server side need both index and html.
    updateIndex(doc_id, index)
    writeArticle(doc_id, html)
    if files:
        updateFiles(files)
Exemple #3
0
    def test_basic(self):
        b = get_browser()
        query = Data()
        query.cmd = 'articles_length'

        url = config.url_root + 'api.py?' + query.urlencode()
        b.go(url)
        result = b.get_html()
        # For Secure key. server is using secure key?
        self.assertNotEqual(result.find('Error'), -1)

        # For articles_length
        query.secure_key = config.SECURE_KEY
        url = config.url_root + 'api.py?' + query.urlencode()

        b.go(url)
        result = b.get_html()
        self.assertEqual(libs.removeBlank(result), '2')

        # For comments_length
        query.cmd = 'comments_length'
        query.doc_id = Var.dummy_id

        url = config.url_root + 'api.py?' + query.urlencode()
        b.go(url)
        result = b.get_html()
        self.assertEqual(libs.removeBlank(result), '1')

        # For article_json
        query.cmd = 'article_json'
        url = config.url_root + 'api.py?' + query.urlencode()
        b.go(url)
        result = b.get_html()
        # Get the index of the local dummy
        article = Article()
        article.set(Var.dummy_id)
        result = json.loads(libs.removeBlank(result))
        self.assertEqual(result['doc_id'], unicode(article.__dict__['doc_id']))
Exemple #4
0
 def getJson(self):
     article = Article()
     article.setFromId(self.doc_id)
     return article.__dict__
Exemple #5
0
def getArticleInfosAsJson (doc_id):
    article = Article()
    article.setFromId(doc_id)
    return json.dumps(article.__dict__)