def blogger_deletePost(request, appkey, postid, username, password, publish):
    """
    Delete an existing post
    """
    # Really want to implement this? hmmm
    authenticate(request, username, password)
    config = request.getConfiguration()
    url = config.get('base_url', '')
    cache_driver = tools.importName('Pyblosxom.cache', 
            config.get('cacheDriver', 'base'))
    cache = cache_driver.BlosxomCache(request, config.get('cacheConfig', ''))
    fn = os.path.normpath(os.path.join(config['datadir'], postid))

    data = request.getData()
    extensions = data['extensions']
    for e in extensions.keys():
        filename = fn+'.'+e
        if os.path.isfile(filename):
            break
            
    if os.path.isfile(filename):
        if cache.has_key(filename):
            del cache[filename]
        os.remove(filename)
        return xmlrpclib.True
    else:
        raise xmlrpclib.Fault('DeleteError','Post does not exist')
Beispiel #2
0
def blogger_deletePost(request, appkey, postid, username, password, publish):
    """
    Delete an existing post
    """
    # Really want to implement this? hmmm
    authenticate(request, username, password)
    config = request.getConfiguration()
    url = config.get('base_url', '')
    cache_driver = tools.importName('Pyblosxom.cache',
                                    config.get('cacheDriver', 'base'))
    cache = cache_driver.BlosxomCache(request, config.get('cacheConfig', ''))
    fn = os.path.normpath(os.path.join(config['datadir'], postid))

    data = request.getData()
    extensions = data['extensions']
    for e in extensions.keys():
        filename = fn + '.' + e
        if os.path.isfile(filename):
            break

    if os.path.isfile(filename):
        if cache.has_key(filename):
            del cache[filename]
        os.remove(filename)
        return xmlrpclib. True
    else:
        raise xmlrpclib.Fault('DeleteError', 'Post does not exist')
Beispiel #3
0
def autoping(name):
    request = Request()
    # Load up the cache (You can just import the base cache here)
    cache_driver = tools.importName('Pyblosxom.cache', config.py.get('cacheDriver', 'base'))
    cache = cache_driver.BlosxomCache(request, config.py.get('cacheConfig', ''))
    try:
        filename = os.path.join(config.py['datadir'], name)
        entryData = {}
        cache.load(filename)
        # Look for cached documents
        if cache.isCached():
            entryData = cache.getEntry()
            
        # Cached? Try our entryparsers then.
        if not entryData:
            fileExt = re.search(r'\.([\w]+)$', filename)
            try:
                entryData = blosxom_entry_parser(filename, request)
            except IOError, e:
                tools.log(e)
        
        name = re.sub(config.py['datadir'],'',name)
        parser = link(name, entryData['title'].strip(), entryData['body'].strip(), config.py['blog_title'])
        trackback(parser)
        pingback(parser)
Beispiel #4
0
def blogger_editPost(request,
                     appkey,
                     postid,
                     username,
                     password,
                     content,
                     publish=1):
    """
    Edit an existing post
    """
    authenticate(request, username, password)
    config = request.getConfiguration()
    filename = os.path.normpath(os.path.join(config['datadir'], postid[1:]))
    if publish and re.search(r'-$', filename):
        switchTo = re.sub(r'-$', '', filename)
    elif not publish and re.search(r'txt$', filename):
        switchTo = filename + '-'
    else:
        switchTo = filename
    cache_driver = tools.importName('Pyblosxom.cache',
                                    config.get('cacheDriver', 'base'))
    cache = cache_driver.BlosxomCache(request, config.get('cacheConfig', ''))
    # Check if file exists or not, edit everything here
    if os.path.isfile(filename):
        if filename != switchTo:
            if cache.has_key(filename):
                del cache[filename]
            os.remove(filename)

            if os.path.isfile(switchTo):
                basefilename, ext = os.path.splitext(
                    os.path.basename(switchTo))
                dirname = os.path.dirname(switchTo)
                switchTo = os.path.normpath(
                    os.path.join(
                        config['datadir'], dirname[1:] + basefilename +
                        tools.generateRandStr() + ext))
        open(switchTo, 'w').write(content)

        return xmlrpclib. True
    else:
        raise xmlrpclib.Fault('UpdateError', 'Post does not exist')
def blogger_editPost(request, appkey, postid, username, password, content,
        publish=1):
    """
    Edit an existing post
    """
    authenticate(request, username, password)
    config = request.getConfiguration()
    filename = os.path.normpath(os.path.join(config['datadir'], postid[1:]))
    if publish and re.search(r'-$', filename):
        switchTo = re.sub(r'-$','',filename)
    elif not publish and re.search(r'txt$', filename):
        switchTo = filename + '-'
    else:
        switchTo = filename
    cache_driver = tools.importName('Pyblosxom.cache', 
            config.get('cacheDriver', 'base'))
    cache = cache_driver.BlosxomCache(request, config.get('cacheConfig', ''))
    # Check if file exists or not, edit everything here
    if os.path.isfile(filename):
        if filename != switchTo:
            if cache.has_key(filename):
                del cache[filename]
            os.remove(filename)

            if os.path.isfile(switchTo):
                basefilename, ext = os.path.splitext(os.path.basename(switchTo))
                dirname = os.path.dirname(switchTo)
                switchTo = os.path.normpath(
                    os.path.join(
                        config['datadir'], dirname[1:] + basefilename +
                        tools.generateRandStr() + ext
                    )
                )
        open(switchTo, 'w').write(content)
                
        return xmlrpclib.True
    else:
        raise xmlrpclib.Fault('UpdateError','Post does not exist')