• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python store.getWeblib函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _buildTags

def _buildTags(req):
    """
    Build base_tag and form_tag. base_tag is the existing tag queried
    by tid. form_tag is a new tag instance build from parsing the form
    fields plus existing data.

    @return (base_tag, form_tag) or None if tid doesn't match any tag.
    """
    wlib = store.getWeblib()
    base_tag = wlib.tags.getById(req.tid)
    if not base_tag:
        return None

    if req.method == 'GET':
        form_tag = base_tag.__copy__()
    else:
        name = req.param('name') or ' '             # avoid empty string
        form_tag = weblib.Tag(
            id          = req.tid,                  # should be same
            name        = name,                     # from form
            description = base_tag.description,     # from repository
            flags       = base_tag.flags,           # from repository
        )
        # HACK! Got around the empty string check in Tag.__init__
        if not req.param('name'):
            form_tag.name = ''

    return base_tag, form_tag
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:28,代码来源:weblibTagForm.py


示例17: doDeleteResource

def doDeleteResource(wfile, base_tag):
    wlib = store.getWeblib()

    log.info('Deleting Tag %s' % unicode(base_tag))
    wlib.tag_merge_del(base_tag, None)

    response.redirect(wfile, '/updateParent?url=/weblib')
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:7,代码来源:weblibTagForm.py


示例18: doDeleteResource

def doDeleteResource(wfile, req):
    wlib = store.getWeblib()
    item = wlib.webpages.getById(req.rid)
    if item:
        log.info('Deleting WebPage %s' % unicode(item))
        store.getStore().removeItem(item)

    response.redirect(wfile, '/updateParent')
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:8,代码来源:weblibForm.py


示例19: test_PUT_existing

  def test_PUT_existing(self):
    wlib = store.getWeblib()
    self.assertEqual(len(wlib.webpages),5)
    item = wlib.webpages.getById(1)
    self.assertEqual(item.name, 'MindRetrieve - Search Your Personal Web')

    # PUT form
    self.checkPathForPattern('/weblib/1?' + urllib.urlencode({
            'method': 'PUT',
            'url': 'http://www.mindretrieve.net/',
            'title': 'Test Title',
            'description': 'some description',
            'created': '1902',
            'modified': '1900',
            'lastused': '1901',
            'tags': 'Kremlin, English',
            'nickname': '_nickname_',
        }),[
        'HTTP/1.0 302 Found',
        'location: /updateParent',
    ])

    # one item has changed
    self.assertEqual(len(wlib.webpages),5)
    item = wlib.webpages.getById(1)
    self.assertEqual(item.name       , 'Test Title')
    self.assertEqual(item.description, 'some description')
    self.assertEqual(item.url        , 'http://www.mindretrieve.net/')
    self.assertEqual(item.created    , '1902')
#    self.assertEqual(item.modified   , '1900')
#    self.assertEqual(item.lastused   , '1901')
    tags = ','.join(sorted(tag.name.lower() for tag in item.tags))
    self.assertEqual(tags, 'english,kremlin')
    self.assertEqual(item.nickname, '_nickname_')

    # PUT partial parameters (only URL)
    self.checkPathForPattern('/weblib/1?' + urllib.urlencode({
            'method': 'PUT',
            'url': 'new url',
        }),[
        'HTTP/1.0 302 Found',
        'location: /updateParent',
    ])

    # url has changed
    item = wlib.webpages.getById(1)
    self.assertEqual(item.url        , 'new url')
    # the rest is unchanged
    self.assertEqual(item.name       , 'Test Title')
    self.assertEqual(item.description, 'some description')
    self.assertEqual(item.created    , '1902')
#    self.assertEqual(item.modified   , '1900')
#    self.assertEqual(item.lastused   , '1901')
    tags = ','.join(sorted(tag.name.lower() for tag in item.tags))
    self.assertEqual(tags, 'english,kremlin')
    self.assertEqual(item.nickname, '_nickname_')
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:56,代码来源:test_weblibForm.py


示例20: doDelete

def doDelete(wfile, req):
    wlib = store.getWeblib()
    entries = _buildEntries(req)
    for item in entries:
        try:
            log.debug('Delete web page: %s', unicode(item))
            store.getStore().removeItem(item)
        except:
            log.exception('Unable to delete: %s', unicode(item))
    response.redirect(wfile, '/updateParent')
开发者ID:BackupTheBerlios,项目名称:mindretrieve-svn,代码行数:10,代码来源:weblibMultiForm.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mineos.mc函数代码示例发布时间:2022-05-27
下一篇:
Python vtks.read_vtk函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap