当前位置: 首页>>代码示例>>Python>>正文


Python store.getWeblib函数代码示例

本文整理汇总了Python中minds.weblib.store.getWeblib函数的典型用法代码示例。如果您正苦于以下问题:Python getWeblib函数的具体用法?Python getWeblib怎么用?Python getWeblib使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getWeblib函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_buildCategoryList

  def test_buildCategoryList(self):
    cat_nodes = weblib_cgi._buildCategoryList(store.getWeblib(), '')
    self.assertTrue(not cat_nodes[0][0].highlight)
    self.assertEqual(self._str_cat_nodes(cat_nodes), [
        u'Kremlin',
        u'.Русский',
        u'.Français',
        u'.日本語',
        u'.English',
    ])

    # highlight a top level cat
    cat_nodes = weblib_cgi._buildCategoryList(store.getWeblib(), 'Kremlin')
    self.assertTrue(cat_nodes[0][0].highlight)
    self.assertEqual(self._str_cat_nodes(cat_nodes), [
        u'Kremlin',
        u'.Русский',
        u'.Français',
        u'.日本語',
        u'.English',
    ])

    # highlight a subcat
    cat_nodes = weblib_cgi._buildCategoryList(store.getWeblib(), 'English')
    self.assertEqual(self._str_cat_nodes(cat_nodes), [
        u'Kremlin',
        u'.Русский',
        u'.Français',
        u'.日本語',
        u'[',
        u'.English',
        u']',
    ])
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:33,代码来源:test_weblib.py

示例2: test_POST_category_collapse

  def test_POST_category_collapse(self):
    wlib = store.getWeblib()

    self.assertTrue('c' not in wlib.tags.getById(124).flags)

    # turn it on
    self.checkPathForPattern("/weblib/@124/form?method=POST&category_collapse=on", [
        '200 OK',
        'setCategoryCollapse @124 True',
    ])
    self.assertTrue('c' in wlib.tags.getById(124).flags)

    # turn it off
    self.checkPathForPattern("/weblib/@124/form?method=POST&category_collapse=", [
        '200 OK',
        'setCategoryCollapse @124 False',
    ])
    self.assertTrue('c' not in wlib.tags.getById(124).flags)

    # turn it off again
    self.checkPathForPattern("/weblib/@124/form?method=POST&category_collapse=", [
        '200 OK',
        'setCategoryCollapse @124 False',
    ])
    self.assertTrue('c' not in wlib.tags.getById(124).flags)
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:25,代码来源:test_weblibTagForm.py

示例3: queryTag

def queryTag(wfile, req, nameOrId):
    wlib = store.getWeblib()

    tag = weblib.parseTag(wlib, nameOrId)
    tagName = tag and tag.name or ''

    # Note: URL is expected to have valid tag parameter. If it turns up
    # nothing, one possibility is user has entered an invalid URL
    # manually. In that case the query below should turn out empty
    # result. We choose not go for the alternative or redirecting user
    # to / or inbox because it seems even more confusing.

    # category pane
    categoryList = _buildCategoryList(wlib, tagName)

    # webitem pane
    if tag:
        webItems = _query_by_tag(wlib, tag)
    else:
        # TODO: HACK!!!
        # Create a fake tag to fill something in the result
        # Seems WeblibRenderer() is OK with this
        fakeTagNode = WebItemTagNode(nameOrId)
        webItems = [fakeTagNode]

    renderer = WeblibRenderer(wfile)
    renderer.setLayoutParam(None)
    renderer.output(
        wlib.tags,
        tag,
        wlib.getDefaultTag(),
        categoryList,
        webItems)
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:33,代码来源:weblib.py

示例4: test_POST

 def test_POST(self):
   test_data = 'a\r\n  b'
   self.checkPathForPattern('/weblib/tag_categorize?category_description=' + urllib.quote(test_data) + '&method=POST', [
       'HTTP/1.0 302 Found',
       'location: /weblib',
   ])
   self.assertEqual(store.getWeblib().category.getDescription(), test_data)
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:7,代码来源:test_weblibTagCategorize.py

示例5: test_PUT_char_workout

  def test_PUT_char_workout(self):
    # test_PUT_input_escape() is a quick basic test
    # this one is going to give character escaping a good work out
    url = '/weblib/_?' + urllib.urlencode({
            'method': 'PUT',
            'title': u'€!"#$%&\'()*+,-. /0123456789: ;<=>[email protected][\\]^_`{|}~'.encode('utf8'),
            'description': u'description:€!"#$%&\'()*+,-. /0123456789: ;<=>[email protected][\\]^_`{|}~\r\n[For testing]'.encode('utf8'),
            'url': u'url:€!"#$%&\'()*+,-. /0123456789: ;<=>[email protected][\\]^_`{|}~'.encode('utf8'),
            'tags': u'€!"$% &\'()*-./; =?[\\]^ _`{|}~'.encode('utf8'),
            'create_tags': '1'
        })
    self.checkPathForPattern(url,[
        'HTTP/1.0 302 Found',
        'location: /updateParent',
    ])

    # one item has added
    wlib = store.getWeblib()
    tag = wlib.tags.getByName(u'€!"$% &\'()*-./; =?[\\]^ _`{|}~')
    self.assert_(tag)

    lastId = wlib.webpages._lastId      # undocumented
    page = wlib.webpages.getById(lastId)
    self.assert_(page)
    self.assertEqual(page.name,        u'€!"#$%&\'()*+,-. /0123456789: ;<=>[email protected][\\]^_`{|}~')
    self.assertEqual(page.description, u'description:€!"#$%&\'()*+,-. /0123456789: ;<=>[email protected][\\]^_`{|}~\r\n[For testing]')
    self.assertEqual(page.url,         u'url:€!"#$%&\'()*+,-. /0123456789: ;<=>[email protected][\\]^_`{|}~')
    self.assertEqual(page.tags,        [tag])
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:28,代码来源:test_weblibForm.py

示例6: test_POST_add_new_tag

  def test_POST_add_new_tag(self):
    wlib = store.getWeblib()

    # before
    self.assertEqual(len(wlib.webpages.getById(2).tags), 2) # Kremlin, Русский
    self.assertEqual(len(wlib.webpages.getById(3).tags), 2) # Kremlin, Français

    url = ''.join(['/weblib/multiform',
            '?id_list=2%2C3',                   # 2 - Russian, 3 - French
            '&%40122=on&%40122changed=1',       # add Français
            '&%40121=on&%40121changed=',        # Русский unchanged
            '&add_tags=aNewTag',
            '&method=POST',
            '&create_tags=1',
            ])
    self.checkPathForPattern(url, [
        'HTTP/1.0 302 Found',
        'location: /updateParent',
    ])

    # after
    newTag = wlib.tags.getByName('aNewTag')
    self.assertTrue(newTag)
    self.assertTrue(newTag.id > 124)            # new tag should have a higher id

    # after
    item = wlib.webpages.getById(2)
    tagIds = sorted([t.id for t in item.tags])
    self.assertEqual(tagIds, [121,122,124,newTag.id]) # Русский, Français, Kremlin, aNewTag

    item = wlib.webpages.getById(3)
    tagIds = sorted([t.id for t in item.tags])
    self.assertEqual(tagIds, [122,124,newTag.id])     # Français, Kremlin, aNewTag
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:33,代码来源:test_weblibMultiForm.py

示例7: test_POST_rename

  def test_POST_rename(self):
    wlib = store.getWeblib()

    # before
    page = wlib.webpages.getById(2)
    tag = wlib.tags.getByName('Kremlin')
    self.assertEqual(len(wlib.tags),6)
    self.assertEqual(tag.name, 'Kremlin')
    self.assertTrue(tag in page.tags)
    self.assertTrue(not wlib.tags.getByName('Buckingham'))
    self.assertTrue('Buckingham' not in wlib.category.getDescription())

    self.checkPathForPattern("/weblib/@124/form?method=POST&name=Buckingham", [
        'HTTP/1.0 302 Found',
        'location: /updateParent',
    ])

    # after
    page = wlib.webpages.getById(2)
    tag = wlib.tags.getByName('Buckingham')
    self.assertEqual(len(wlib.tags),6)
    self.assertEqual(tag.name, 'Buckingham')
    self.assertTrue(tag in page.tags)
    self.assertTrue(not wlib.tags.getByName('Kremlin'))
    self.assertTrue('Buckingham' in wlib.category.getDescription())
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:25,代码来源:test_weblibTagForm.py

示例8: doLaunchURL

def doLaunchURL(wfile, req):
    wlib = store.getWeblib()
    item = wlib.webpages.getById(req.rid)
    if not item:
        wfile.write('404 not found\r\n\r\n%s not found' % req.rid)
        return

    if util.isFileURL(item.url):
        # TODO: HACK win32 only??
        # TODO: It is dangerous to launch anything could be executable or script
        from minds.weblib.win32 import ntfs_util
        ntfs_util.launch(item.url)
        wfile.write('content-type: text/html\r\n')
        wfile.write('Cache-control: no-cache\r\n')
        wfile.write('\r\n')
        wfile.write('''<html>
<head>
  <script>window.close();</script>
</head>
<body>
  File launched in separate window. Please close this window.
</body>
</html>
        ''')
    else:
        response.redirect(wfile, item.url)
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:26,代码来源:weblib.py

示例9: main

def main(wfile, req):
    # this is called from the controller weblib

    # if rid is defined, make sure it is valid
    if req.rid > 0:
        if not store.getWeblib().webpages.getById(req.rid):
            wfile.write('404 not found\r\n\r\n')
            wfile.write('rid %s not found' % req.rid)

    if req.method == 'PUT':
        bean = Bean(req)
        doPutResource(wfile, req, bean)

    elif req.method == 'POST':
        wfile.write('404 Method Not Allowed\r\n\r\n')
        wfile.write('Use PUT to update the item.')

    elif req.method == 'DELETE':
        doDeleteResource(wfile, req)

    else: # otherwise it is GET
        bean = Bean(req)
        if req.rid == -1 and bean.oldItem:
            # if bookmarklet to an existing item, redirect to the appropiate rid
            url = '%s?%s' % (request.rid_url(bean.item.id), req.env.get('QUERY_STRING',''))
            response.redirect(wfile, url)

        else:
            doGetResource(wfile, req, bean)
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:29,代码来源:weblibForm.py

示例10: _parse_PUT

 def _parse_PUT(self, req):
     """
     Parse submission from form
       method: PUT
       parameters: description, title, url, tags, created, modified, lastused
          (plus some more auxiliary parameters?)
     """
     wlib = store.getWeblib()
     if self.oldItem:
         # Update an existing item
         # Selectively update the field if parameter is supplied.
         # That way an API call can send a subset of parameters.
         self.item = self.oldItem.__copy__()
         if 'title'       in req.form: self.item.name         = req.param('title')
         if 'url'         in req.form: self.item.url          = req.param('url')
         if 'description' in req.form: self.item.description  = req.param('description')
         if 'created'     in req.form: self.item.created      = req.param('created')
         if 'modified'    in req.form: self.item.modified     = req.param('modified')
         if 'lastused'    in req.form: self.item.lastused     = req.param('lastused')
         if 'tags'        in req.form: self._parseTags(req)
     else:
         # create new item
         self.item = weblib.WebPage(
             name        = req.param('title'),
             url         = req.param('url'),
             description = req.param('description'),
             created     = req.param('created'),
             modified    = req.param('modified'),
             lastused    = req.param('lastused'),
         )
         self._parseTags(req)
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:31,代码来源:weblibForm.py

示例11: import_bookmarks

def import_bookmarks(bookmarks):
    """
    Import flat collection of bookmarks.
    bookmarks is a list of Bookmark.

    @return (added, updated)
    """
    wlib = store.getWeblib()
    update_count = 0
    add_count = 0
    for b in bookmarks:
        page = weblib.WebPage(
            name        = b.name,
            url         = b.url,
            description = b.description,
            created     = b.created,
            modified    = b.modified,
            )
        page.tags_description = b.tags
        isNew, newPage = wlib.putWebPage(page)
        if isNew:
            update_count += 1
        else:
            add_count += 1
    log.info('Import completed items added=%s updated=%s' % (add_count, update_count))
    return (add_count, update_count)
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:26,代码来源:import_util.py

示例12: queryRoot

def queryRoot(wfile, req, sort):
    wlib = store.getWeblib()

    # category pane
    categoryList = _buildCategoryList(wlib)

    # upgrade_info
    upgrade_info = upgrade_checker.pollUpgradeInfo()

    # webitem pane
    webItems = map(WebItemNode, query_wlib.queryRoot(wlib))

    renderer = WeblibRenderer(wfile)
    if sort:
        renderer.cookie['weblib_sort'] = sort
    renderer.setLayoutParam(None)
    renderer.output(
        '/weblib',
        wlib.tags,
        None,
        wlib.getDefaultTag(),
        categoryList,
        upgrade_info,
        sort,
        webItems,
        )
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:26,代码来源:weblib.py

示例13: build_category

def build_category(folder, state, path=None):
    """ walk the folder tree recursively and build the category description """
    if path == None:
        path = []

    state.cat_buf.write('  ' * (len(path)-1))   # negative is ok
    state.cat_buf.write(folder.name)
    state.cat_buf.write('\n')

    wlib = store.getWeblib()

    path.append(folder)
    tags = ','.join([f.name for f in path])
    for item in folder.children:
        if isinstance(item, Folder):
            build_category(item, state, path)
        else:
            page = weblib.WebPage(
                name        = item.name,
                url         = item.url,
                description = item.description,
                created     = item.created,
                modified    = item.modified,
                )
            page.tags_description = tags
            isNew, newPage = wlib.putWebPage(page)
            if isNew:
                state.update_count += 1
            else:
                state.add_count += 1
    path.pop()
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:31,代码来源:import_util.py

示例14: main

def main(rfile, wfile, env):
    wlib = store.getWeblib()

    req = request.WeblibRequest(rfile, env)
    log.debug(unicode(req))
    path = req.path

    if req.rid:
        # rid based (note rid maybe -1)
        if path and path.startswith('go;'):
            doGoResource(wfile, req)
        elif path and path == 'url':
            doLaunchURL(wfile, req)
        elif path and path.startswith('snapshot'):
            weblibSnapshot.main(wfile, env, req.method, req.form, req.rid, path)
        elif path == 'form':
            doWeblibForm(wfile, req)
        else:
            # show form by default
            doWeblibForm(wfile, req)

    elif req.tid:
        doweblibTagForm(wfile, req)

    else:
        if path == 'load':
            doLoad(wfile, req)
        elif path == 'save':
            doSave(wfile, req)
        else:
            doQuery(wfile, req)
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:31,代码来源:weblib.py

示例15: test_POST_remove

  def test_POST_remove(self):
    wlib = store.getWeblib()

    # before
    self.assertEqual(len(wlib.webpages.getById(2).tags), 2) # Kremlin, Русский
    self.assertEqual(len(wlib.webpages.getById(3).tags), 2) # Kremlin, Français

    url = ''.join(['/weblib/multiform',
            '?id_list=2%2C3',                   # 2 - Russian, 3 - French
            '&%40122=&%40122changed=1',         # remove Français
            '&%40121=on&%40121changed=',        # Русский unchanged
            '&add_tags=inbox',
            '&method=POST',
            ])
    self.checkPathForPattern(url, [
        'HTTP/1.0 302 Found',
        'location: /updateParent',
    ])

    # after
    item = wlib.webpages.getById(2)
    tagIds = sorted([t.id for t in item.tags])
    self.assertEqual(tagIds, [120,121,124])     # inbox, Русский, Kremlin

    item = wlib.webpages.getById(3)
    tagIds = sorted([t.id for t in item.tags])
    self.assertEqual(tagIds, [120,124])         # inbox, Kremlin
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:27,代码来源:test_weblibMultiForm.py


注:本文中的minds.weblib.store.getWeblib函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。