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


Python Tiddler.recipe方法代码示例

本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.recipe方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.recipe方法的具体用法?Python Tiddler.recipe怎么用?Python Tiddler.recipe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tiddlyweb.model.tiddler.Tiddler的用法示例。


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

示例1: add

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
 def add(self, tiddler):
     """
     Add a reference to the tiddler to the container,
     updating the digest and modified information. If
     the tiddler has recently been deleted, resulting
     in a StoreError, simply don't add it.
     """
     if not tiddler.store and self.store:
         try:
             tiddler = self.store.get(tiddler)
         except StoreError, exc:
             LOGGER.debug(
                     'tried to add missing tiddler to collection: %s, %s',
                     tiddler, exc)
             return
         if not self.store.environ['tiddlyweb.config'].get(
                 'collections.use_memory', False):
             reference = Tiddler(tiddler.title, tiddler.bag)
             if tiddler.revision:
                 reference.revision = tiddler.revision
             if tiddler.recipe:
                 reference.recipe = tiddler.recipe
             self._container.append(reference)
         else:
             self._container.append(tiddler)
开发者ID:FND,项目名称:tiddlyweb,代码行数:27,代码来源:collections.py

示例2: get

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def get(environ, start_response):
    """
    Using query parameters, determine the current tiddler
    and produce an editor for it.
    """
    usersign = environ['tiddlyweb.usersign']
    try:
        tiddler_name = environ['tiddlyweb.query'].get('tiddler', [''])[0]
        recipe_name = environ['tiddlyweb.query'].get('recipe', [''])[0]
        bag_name = environ['tiddlyweb.query'].get('bag', [''])[0]
        #tiddler_name = unicode(urllib.unquote(tiddler_name), 'utf-8')
        #bag_name = unicode(urllib.unquote(bag_name), 'utf-8')
        #recipe_name = unicode(urllib.unquote(recipe_name), 'utf-8')
    except (KeyError, IndexError):
        raise HTTP400('tiddler, recipe and bag query strings required')

    store = environ['tiddlyweb.store']

    tiddler = Tiddler(tiddler_name)
    if bag_name:
        tiddler.bag = bag_name
    else:
        recipe = Recipe(recipe_name)
        try:
            recipe = store.get(recipe)
            tiddler.bag = control.determine_tiddler_bag_from_recipe(recipe, tiddler).name
            tiddler.recipe = recipe.name
        except NoRecipeError, exc:
            raise HTTP404('unable to edit %s, recipe %s not found: %s' % (tiddler.title, recipe_name, exc))
        except NoBagError, exc:
            raise HTTP404('unable to edit %s: %s' % (tiddler.title, exc))
开发者ID:FND,项目名称:tiddlywiki-svn-mirror,代码行数:33,代码来源:tiddlywebeditor_plus.py

示例3: add

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
 def add(self, tiddler):
     """
     Add a reference to the :py:class:`tiddler
     <tiddlyweb.model.tiddler.Tiddler>` to the container, updating the
     digest and modified information. If the tiddler has recently been
     deleted, resulting in a :py:class:`StoreError
     <tiddlyweb.store.StoreError>`, don't add it.
     """
     if not tiddler.store and self.store:
         try:
             tiddler = self.store.get(tiddler)
         except StoreError as exc:
             LOGGER.debug(
                     'tried to add missing tiddler to collection: %s, %s',
                     tiddler, exc)
             return
         if not self.store.environ['tiddlyweb.config'].get(
                 'collections.use_memory', False):
             reference = Tiddler(tiddler.title, tiddler.bag)
             if tiddler.revision:
                 reference.revision = tiddler.revision
             if tiddler.recipe:
                 reference.recipe = tiddler.recipe
             self._container.append(reference)
         else:
             self._container.append(tiddler)
     else:
         self._container.append(tiddler)
     self._update_digest(tiddler)
     modified_string = str(tiddler.modified)
     modified_string = modified_string.ljust(14, '0')
     if modified_string > self.modified:
         self.modified = modified_string
开发者ID:24king,项目名称:tiddlyweb,代码行数:35,代码来源:collections.py

示例4: add

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
    def add(self, tiddler):
        """
        Add a reference to the tiddler to the container,
        updating the digest and modified information.
        """
        self._update_digest(tiddler)

        if self.store:
            reference = Tiddler(tiddler.title, tiddler.bag)
            if tiddler.revision:
                reference.revision = tiddler.revision
            if tiddler.recipe:
                reference.recipe = tiddler.recipe

            self._container.append(reference)
        else:
            self._container.append(tiddler)

        try:
            modified_string = str(tiddler.modified)
            modified_string = modified_string.ljust(14, '0')
            if modified_string > self.modified:
                self.modified = modified_string
        except AttributeError:
            pass
开发者ID:jdlrobson,项目名称:tiddlyweb,代码行数:27,代码来源:collections.py

示例5: test_tiddler_url

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def test_tiddler_url():
    tiddler = Tiddler('foobar')
    tiddler.bag = 'zoom'

    url = tiddler_url(environ, tiddler)

    assert url == 'http://our_test_domain:8001/bags/zoom/tiddlers/foobar'

    tiddler.recipe = 'car'

    url = tiddler_url(environ, tiddler, container='recipes')

    assert url == 'http://our_test_domain:8001/recipes/car/tiddlers/foobar'

    url = tiddler_url(environ, tiddler, container='recipes', full=False)

    assert url == '/recipes/car/tiddlers/foobar'

    config['server_prefix'] = '/sleep'

    url = tiddler_url(environ, tiddler, container='recipes', full=False)

    assert url == '/sleep/recipes/car/tiddlers/foobar'

    url = tiddler_url(environ, tiddler)

    assert url == 'http://our_test_domain:8001/sleep/bags/zoom/tiddlers/foobar'

    tiddler.fields['_canonical_uri'] = 'http://example.com'
    url = tiddler_url(environ, tiddler)

    # we decided url is always local
    #assert url == 'http://example.com'
    assert url == 'http://our_test_domain:8001/sleep/bags/zoom/tiddlers/foobar'
开发者ID:FND,项目名称:tiddlyweb,代码行数:36,代码来源:test_web_util.py

示例6: get

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def get(environ, start_response):
    """
    Using query parameters, determine the current tiddler
    and produce an editor for it.
    """
    usersign = environ["tiddlyweb.usersign"]
    try:
        tiddler_name = environ["tiddlyweb.query"].get("tiddler", [""])[0]
        recipe_name = environ["tiddlyweb.query"].get("recipe", [""])[0]
        bag_name = environ["tiddlyweb.query"].get("bag", [""])[0]
    except (KeyError, IndexError):
        raise HTTP400("tiddler, recipe and bag query strings required")

    store = environ["tiddlyweb.store"]

    tiddler = Tiddler(tiddler_name)
    if bag_name:
        tiddler.bag = bag_name
    else:
        recipe = Recipe(recipe_name)
        try:
            recipe = store.get(recipe)
            tiddler.bag = determine_bag_from_recipe(recipe, tiddler).name
            tiddler.recipe = recipe.name
        except NoRecipeError, exc:
            raise HTTP404("unable to edit %s, recipe %s not found: %s" % (tiddler.title, recipe_name, exc))
        except NoBagError, exc:
            raise HTTP404("unable to edit %s: %s" % (tiddler.title, exc))
开发者ID:tiddlyweb,项目名称:tiddlyweb-plugins,代码行数:30,代码来源:tiddlyeditor.py

示例7: _send_tiddler_revisions

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def _send_tiddler_revisions(environ, start_response, tiddler):
    """
    Push the list of tiddler revisions out the network.
    """
    store = environ['tiddlyweb.store']

    title = 'Revisions of Tiddler %s' % tiddler.title
    title = environ['tiddlyweb.query'].get('title', [title])[0]
    container = 'recipes' if tiddler.recipe else 'bags'

    if environ['tiddlyweb.filters']:
        tiddlers = Tiddlers(title=title)
    else:
        tiddlers = Tiddlers(title=title, store=store)

    tiddlers.is_revisions = True
    tiddlers.link = '%s/revisions' % web.tiddler_url(environ, tiddler,
            container=container, full=False)

    recipe = tiddler.recipe
    try:
        for revision in store.list_tiddler_revisions(tiddler):
            tmp_tiddler = Tiddler(title=tiddler.title, bag=tiddler.bag)
            tmp_tiddler.revision = revision
            if recipe:
                tmp_tiddler.recipe = recipe
            tiddlers.add(tmp_tiddler)
    except NoTiddlerError, exc:
        # If a tiddler is not present in the store.
        raise HTTP404('tiddler %s not found, %s' % (tiddler.title, exc))
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:32,代码来源:tiddler.py

示例8: test_html_attribute_escape_with_recipe

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def test_html_attribute_escape_with_recipe():
    tiddler = Tiddler(
            'escape "double" quotes & &amp; in <tiddler> field values')
    tiddler.bag = 'foo "bar" baz'
    tiddler.recipe = 'baz "bar" foo'
    tiddler.modifier = 'Chris "sensei" Dent'
    tiddler.tags = ["foo", 'xxx "yyy" zzz']
    tiddler.fields["custom"] = u"""lorem 'ipsum' dolor "sit" amet"""
    tiddler.text = ''
    serializer = Serializer('tiddlywebwiki.serialization', environ)
    serializer.object = tiddler
    string = serializer.to_string()

    assert ('title="escape &quot;double&quot; quotes &amp; '
        '&amp;amp; in &lt;tiddler&gt; field values"' in string)
    assert ('server.title="escape &quot;double&quot; quotes &amp; '
        '&amp;amp; in &lt;tiddler&gt; field values"' in string)
    assert 'bag="foo &quot;bar&quot; baz"' in string
    assert 'recipe="baz &quot;bar&quot; foo"' in string
    assert 'server.workspace="bags/foo &quot;bar&quot; baz"' in string
    assert 'modifier="Chris &quot;sensei&quot; Dent"' in string
    assert 'creator="Chris &quot;sensei&quot; Dent"' in string
    assert 'tags="foo [[xxx &quot;yyy&quot; zzz]]"' in string
    assert '''custom="lorem 'ipsum' dolor &quot;sit&quot; amet"''' in string
    # single tiddler's browse link is that tiddler in its bag
    assert ('you may still <a href="/bags/foo%20%22bar%22%20baz/tiddlers'
            '/escape%20%22double%22%20quotes%20%26%20%26amp%3B%20in%20%3C'
            'tiddler%3E%20field%20values">browse' in string)
开发者ID:tiddlyweb,项目名称:tiddlywebwiki,代码行数:30,代码来源:test_serialize_tiddler.py

示例9: wikifier

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def wikifier(mystr, path):
    """
    Render TiddlyWiki wikitext in the provided
    string to HTML. This function taken and modified
    from wikklytextrender.py
    """
    tiddler = Tiddler('tmp')
    tiddler.text = mystr
    tiddler.recipe = path
    environ={'tiddlyweb.config': config}
    return render_wikitext(tiddler, environ)
开发者ID:bengillies,项目名称:TiddlyWeb-Plugins,代码行数:13,代码来源:wikifier.py

示例10: test_simple_render

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def test_simple_render():
    tiddler = Tiddler('bar')
    tiddler.text = 'Hello [[monkey]]!'
    tiddler.bag = 'zoo'

    html = render(tiddler, {})
    assert 'href="/bags/zoo/tiddlers/monkey"' in html

    tiddler.recipe = 'city'
    html = render(tiddler, {})
    assert 'href="/recipes/city/tiddlers/monkey"' in html

    html = render(tiddler, {'tiddlyweb.config': {'server_prefix': '/wiki'}})
    assert 'href="/wiki/recipes/city/tiddlers/monkey"' in html
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.wikklytextrender,代码行数:16,代码来源:test_prefix_handling.py

示例11: test_base_output

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def test_base_output():
    tiddler = Tiddler('link thing', 'fake')
    tiddler.text = TEXT

    serializer.object = tiddler
    output = serializer.to_string()

    assert 'xml:base="http://0.0.0.0:8080/bags/fake/tiddlers/"' in output

    tiddler.recipe = 'carnage'

    serializer.object = tiddler
    output = serializer.to_string()

    assert 'xml:base="http://0.0.0.0:8080/recipes/carnage/tiddlers/"' in output
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.atom,代码行数:17,代码来源:test_base_href.py

示例12: add

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
 def add(self, tiddler):
     """
     Add a reference to the tiddler to the container,
     updating the digest and modified information. If
     the tiddler has recently been deleted, resulting
     in a StoreError, simply don't add it.
     """
     if not tiddler.store and self.store:
         try:
             tiddler = self.store.get(tiddler)
         except StoreError, exc:
             logging.debug("tried to add missing tiddler to collection: %s, %s", tiddler, exc)
             return
         reference = Tiddler(tiddler.title, tiddler.bag)
         if tiddler.revision:
             reference.revision = tiddler.revision
         if tiddler.recipe:
             reference.recipe = tiddler.recipe
         self._container.append(reference)
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:21,代码来源:collections.py

示例13: mapper

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
 def mapper(atom_field_name,tiddler,default):
     logging.debug("atom-custom:: doing a mapping on field %s \n atom-custom::with tiddler %s \n atom-custom::and config %s"%(atom_field_name,tiddler,mappings))
     tid = Tiddler(tiddler['title'],tiddler['bag'])
     tid = serializer.as_tiddler(tid,tiddler)
     try:
         tid.recipe = tiddler['recipe']
     except KeyError:
         pass
     if atom_field_name in mappings:
       val = mappings[atom_field_name]
       if atom_field_name == 'link' or atom_field_name == 'id' and val.startswith("/"):
         sh =config['server_host']
         val = u"%s://%s%s"%(sh['scheme'],sh['host'],val)
         wikified = "http://%s"%wikitext_to_wikklyhtml(baseurl, '', val[7:], self.environ,tiddler=tid,wikiwords=False)
       else:
         wikified = wikitext_to_wikklyhtml(baseurl, '', val, self.environ,tiddler=tid,wikiwords=False)
       return cgi.escape(wikified).decode("utf-8")
       
     else:
       return default
开发者ID:jdlrobson,项目名称:tiddlyweb-plugins,代码行数:22,代码来源:atomcustom.py

示例14: add

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
 def add(self, tiddler):
     """
     Add a reference to the tiddler to the container,
     updating the digest and modified information.
     """
     if not tiddler.store and self.store:
         tiddler = self.store.get(tiddler)
         reference = Tiddler(tiddler.title, tiddler.bag)
         if tiddler.revision:
             reference.revision = tiddler.revision
         if tiddler.recipe:
             reference.recipe = tiddler.recipe
         self._container.append(reference)
     else:
         self._container.append(tiddler)
     self._update_digest(tiddler)
     modified_string = str(tiddler.modified)
     modified_string = modified_string.ljust(14, '0')
     if modified_string > self.modified:
         self.modified = modified_string
开发者ID:chancejiang,项目名称:tiddlyweb,代码行数:22,代码来源:collections.py

示例15: _send_tiddler_revisions

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import recipe [as 别名]
def _send_tiddler_revisions(environ, start_response, tiddler):
    """
    Push the list of tiddler revisions out the network.
    """
    store = environ['tiddlyweb.store']

    title = 'Revisions of Tiddler %s' % tiddler.title
    title = environ['tiddlyweb.query'].get('title', [title])[0]
    tiddlers = Tiddlers(title=title, store=store)
    tiddlers.is_revisions = True
    recipe = tiddler.recipe
    try:
        for revision in store.list_tiddler_revisions(tiddler):
            tmp_tiddler = Tiddler(title=tiddler.title, bag=tiddler.bag)
            tmp_tiddler.revision = revision
            if recipe:
                tmp_tiddler.recipe = recipe
            tiddlers.add(tmp_tiddler)
    except NoTiddlerError, exc:
        # If a tiddler is not present in the store.
        raise HTTP404('tiddler %s not found, %s' % (tiddler.title, exc))
开发者ID:chancejiang,项目名称:tiddlyweb,代码行数:23,代码来源:tiddler.py


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