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


Python Recipe.set_recipe方法代码示例

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


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

示例1: _init_store

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
    def _init_store(self, struct):
        """
        creates basic store structure with bags, recipes and users

        (no support for user passwords for security reasons)
        """
        store = get_store(self.init_config)

        bags = struct.get("bags", {})
        for name, data in bags.items():
            desc = data.get("desc")
            bag = Bag(name, desc=desc)
            constraints = data.get("policy", {})
            _set_policy(bag, constraints)
            store.put(bag)

        recipes = struct.get("recipes", {})
        for name, data in recipes.items():  # TODO: DRY
            desc = data.get("desc")
            recipe = Recipe(name, desc=desc)
            recipe.set_recipe(data["recipe"])
            constraints = data.get("policy", {})
            _set_policy(recipe, constraints)
            store.put(recipe)

        users = struct.get("users", {})
        for name, data in users.items():
            note = data.get("note")
            user = User(name, note=note)
            password = data.get("_password")
            if password:
                user.set_password(password)
            for role in data.get("roles", []):
                user.add_role(role)
            store.put(user)
开发者ID:FND,项目名称:tiddlywebplugins.imaker,代码行数:37,代码来源:imaker.py

示例2: _make_recipe

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def _make_recipe(recipe_name, bags):
    """Make a recipe with recipe_name."""
    recipe = Recipe(recipe_name)
    recipe_list = [[bag, ''] for bag in bags]
    recipe.set_recipe(recipe_list)
    store = Store(config['server_store'][0], environ={'tiddlyweb.config': config})
    store.put(recipe)
开发者ID:angeluseve,项目名称:tiddlyweb,代码行数:9,代码来源:instancer.py

示例3: setup_store

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def setup_store():
    """
    initialise a blank store, and fill it with some data
    """
    store = get_store(config)
    for bag in BAGS:
        bag = Bag(bag)
        try:
            store.delete(bag)
        except NoBagError:
            pass
        
        store.put(bag)
    
    for recipe, contents in RECIPES.iteritems():
        recipe = Recipe(recipe)
        try:
            store.delete(recipe)
        except NoRecipeError:
            pass
        
        recipe.set_recipe(contents)
        store.put(recipe)
        
    return store
开发者ID:jdlrobson,项目名称:tiddlywebplugins.form,代码行数:27,代码来源:setup_test.py

示例4: test_unicode_in_recipes

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def test_unicode_in_recipes():
    """
    visit a recipe passing unicode in as one of the variables
    """
    store = setup_store()
    url(['/foo/{bar:segment}', '/recipes/custom/tiddlers'])
    urls_init(config)
    setup_web()
    http = httplib2.Http()

    bag = Bag(u'unicodeø•º∆∆˙ª')
    store.put(bag)
    tiddler = Tiddler(u'bar œ∑´®†¥', u'unicodeø•º∆∆˙ª')
    tiddler.text = 'foo bar'
    store.put(tiddler)

    recipe = Recipe('custom')
    recipe.set_recipe([('{{ bar:foo }}', '')])
    store.put(recipe)

    response, content = http.request('http://test_domain:8001/foo/unicodeø•º∆∆˙ª')

    assert response.status == 200

    direct_url = http.request(u'http://test_domain:8001/recipes/custom/tiddlers')[1]
    assert content != direct_url #direct_url should load the foo bag instead

    recipe.set_recipe([(u'unicodeø•º∆∆˙ª', '')])
    store.put(recipe)
    direct_url = http.request(u'http://test_domain:8001/recipes/custom/tiddlers')[1]
    assert content == direct_url
开发者ID:bengillies,项目名称:tiddlywebplugins.urls,代码行数:33,代码来源:test_unicode.py

示例5: test_get_recipe_list_templated_bag

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def test_get_recipe_list_templated_bag():
    recipe = Recipe('tr')
    recipe.set_recipe([
        ('{{ user }}', '')
        ])
    list = recipe.get_recipe({'user': 'testuser'})
    assert list[0][0] == 'testuser'
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:9,代码来源:test_recipe.py

示例6: setup_module

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def setup_module(module):

    module.store = get_store(config)

    # cascade to deal with differently named files depending on 
    # anydbm impelementation
    try:
        os.unlink('links.db')
    except OSError:
        pass  # not there
    module.links_manager = LinksManager()

    try:
        shutil.rmtree('store')
    except:
        pass
    
    def app():
        return serve.load_app()
    httplib2_intercept.install()
    wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app)

    # for @someone syntax to test correctly we need a corresponding
    # recipe
    module.store.put(Bag('cdent_public'))
    recipe = Recipe('cdent_public')
    recipe.set_recipe([('cdent_public', '')])
    module.store.put(recipe)
开发者ID:FND,项目名称:tiddlywebplugins.links,代码行数:30,代码来源:test_tiddler.py

示例7: test_get_recipe_list_templated_filter2

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def test_get_recipe_list_templated_filter2():
    recipe = Recipe('tr')
    recipe.set_recipe([
        ('system', 'modifier={{ user }};creator={{ user }}')
        ])
    list = recipe.get_recipe({'user': 'testuser'})
    assert list[0][1] == 'modifier=testuser;creator=testuser'
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:9,代码来源:test_recipe.py

示例8: test_put_recipe

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def test_put_recipe():
    recipe = Recipe('cookies')
    recipe.set_recipe(recipe_list)

    store.put(recipe)

    assert os.path.exists('store/recipes/cookies')
开发者ID:angeluseve,项目名称:tiddlyweb,代码行数:9,代码来源:test_roundtrip.py

示例9: make_space

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def make_space(space_name, store, member):
    """
    The details of creating the bags and recipes that make up a space.
    """
    space = Space(space_name)

    for bag_name in space.list_bags():
        bag = Bag(bag_name)
        bag.policy = _make_policy(member)
        if Space.bag_is_public(bag_name):
            bag.policy.read = []
        store.put(bag)

    info_tiddler = Tiddler('SiteInfo', space.public_bag())
    info_tiddler.text = 'Space %s' % space_name
    store.put(info_tiddler)

    public_recipe = Recipe(space.public_recipe())
    public_recipe.set_recipe(space.public_recipe_list())
    private_recipe = Recipe(space.private_recipe())
    private_recipe.set_recipe(space.private_recipe_list())
    private_recipe.policy = _make_policy(member)
    public_recipe.policy = _make_policy(member)
    public_recipe.policy.read = []
    store.put(public_recipe)
    store.put(private_recipe)
开发者ID:ramanathanr,项目名称:tiddlyspace,代码行数:28,代码来源:spaces.py

示例10: _make_space

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def _make_space(environ, space_name):
    """
    The details of creating the bags and recipes that make up a space.
    """
    store = environ['tiddlyweb.store']
    member = environ['tiddlyweb.usersign']['name']

    # XXX stub out the clumsy way for now
    # can make this much more declarative

    space = Space(space_name)

    for bag_name in space.list_bags():
        bag = Bag(bag_name)
        bag.policy = _make_policy(member)
        if Space.bag_is_public(bag_name):
            bag.policy.read = []
        store.put(bag)

    public_recipe = Recipe(space.public_recipe())
    public_recipe.set_recipe(space.public_recipe_list())
    private_recipe = Recipe(space.private_recipe())
    private_recipe.set_recipe(space.private_recipe_list())
    private_recipe.policy = _make_policy(member)
    public_recipe.policy = _make_policy(member)
    public_recipe.policy.read = []
    store.put(public_recipe)
    store.put(private_recipe)
开发者ID:carnotip,项目名称:tiddlyspace,代码行数:30,代码来源:spaces.py

示例11: setup_module

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def setup_module(module):
    try:
        shutil.rmtree('store')
    except:
        pass
    config['markdown.wiki_link_base'] = ''
    store = get_store(config)

    environ['tiddlyweb.store'] = store

    store.put(Bag('bag'))
    module.store = store

    recipe = Recipe('recipe_public')
    recipe.set_recipe([('bag', '')])
    store.put(recipe)

    tiddlerA = Tiddler('tiddler a', 'bag')
    tiddlerA.text = 'I am _tiddler_'
    store.put(tiddlerA)

    tiddlerB = Tiddler('tiddler b')
    tiddlerB.text = '''
You wish

{{tiddler a}}

And I wish too.
'''
    module.tiddlerB = tiddlerB
开发者ID:FND,项目名称:tiddlywebplugins.markdown,代码行数:32,代码来源:test_transclusion.py

示例12: test_index_query_in_recipe

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def test_index_query_in_recipe():
    config['indexer'] = 'test.indexernot'

    bag = Bag('noop')
    store.put(bag)
    tiddler = Tiddler('dwell', 'noop')
    store.put(tiddler)

    recipe = Recipe('coolio')
    recipe.set_recipe([('noop', u''), ('fwoop', u'')])
    recipe.store = store

    tiddler = Tiddler('swell')
    py.test.raises(ImportError,
            'determine_bag_from_recipe(recipe, tiddler, environ)')

    config['indexer'] = 'test.indexer'
    bag = determine_bag_from_recipe(recipe, tiddler, environ)
    assert bag.name == 'fwoop'

    tiddler = Tiddler('dwell')
    bag = determine_bag_from_recipe(recipe, tiddler, environ)
    assert bag.name == 'noop'

    tiddler = Tiddler('carnaby')  # nowhere
    py.test.raises(NoBagError,
            'determine_bag_from_recipe(recipe, tiddler, environ)')
开发者ID:24king,项目名称:tiddlyweb,代码行数:29,代码来源:test_control.py

示例13: _create_recipe

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def _create_recipe(environ):
    """Take the form input and turn it into a recipe."""
    # get bag_names before we flatten because it will be a list
    bag_names = environ['tiddlyweb.query'].get('bags', [])
    query_data = _flatten_form_data(environ['tiddlyweb.query'])
    store = environ['tiddlyweb.store']
    try:
        new_recipe_name = query_data['recipe_name']

        if _recipe_exists(store, new_recipe_name):
            raise HTTP409('That recipe may not be created.')

        new_recipe = Recipe(new_recipe_name)

        username = environ['tiddlyweb.usersign']['name']
        new_recipe.policy.owner = username
        new_recipe.policy.manage = [username]
        new_recipe.desc = query_data.get('recipe_desc', '')

        privacy = query_data['privacy']
        new_recipe.policy.read = _policy_form_to_entry(username, privacy)

        bag_list = []

        if query_data.get('autowiki', 0):
            bag_list.extend(AUTOWIKI_BAGS)

        # don't worry about default content bag yet
        bag_list.extend(bag_names)
        recipe_list = [[bag_name, ''] for bag_name in bag_list]
        new_recipe.set_recipe(recipe_list)

        store.put(new_recipe)
    except KeyError, exc:
        raise HTTP400('something went wrong processing for: %s' % exc)
开发者ID:FND,项目名称:tiddlyweb-plugins-1,代码行数:37,代码来源:mine.py

示例14: test_recipe_variables

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def test_recipe_variables():
    """
    access a recipe with variables in it
    """
    store = setup_store()
    url(['/foo/{name:segment}', '/recipes/custom/tiddlers'])
    urls_init(config)
    setup_web()
    http = httplib2.Http()

    tiddler = Tiddler('bar', 'foo')
    tiddler.text = 'foo bar'
    store.put(tiddler)

    recipe = Recipe('custom')
    recipe.set_recipe([('{{ name:bar }}', '')])
    store.put(recipe)

    response, content = http.request('http://test_domain:8001/foo/foo')

    assert response.status == 200

    direct_url = http.request('http://test_domain:8001/recipes/custom/tiddlers')[1]
    assert content != direct_url #accessing directly, the default bag should be used instead

    #now check that the correct bag was actually loaded)
    recipe.set_recipe([('foo', '')])
    store.put(recipe)
    direct_url = http.request('http://test_domain:8001/recipes/custom/tiddlers')[1]
    assert content == direct_url
开发者ID:bengillies,项目名称:tiddlywebplugins.urls,代码行数:32,代码来源:test_variables.py

示例15: test_determine_tiddler_from_recipe

# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import set_recipe [as 别名]
def test_determine_tiddler_from_recipe():
    """
    Work out what bag a provided tiddler is in, when we have no knowledge of the bag,
    but we do have a recipe.
    """
    short_recipe = Recipe(name='foobar')
    short_recipe.set_recipe([
        [bagone, ''],
        [bagfour, 'select=tag:tagone']
        ])
    bag = control.determine_tiddler_bag_from_recipe(short_recipe, tiddlers[0])
    assert bag.name == bagfour.name, 'bag name should be bagfour, is %s' % bag.name

    short_recipe.set_recipe([
        [bagone, ''],
        [bagfour, 'select=tag:tagthree']
        ])
    bag = control.determine_tiddler_bag_from_recipe(short_recipe, tiddlers[0])
    assert bag.name == bagone.name, 'bag name should be bagone, is %s' % bag.name

    lonely_tiddler = Tiddler('lonely')
    lonely_tiddler.bag = 'lonelybag'

    py.test.raises(NoBagError,
            'bag = control.determine_tiddler_bag_from_recipe(short_recipe, lonely_tiddler)')
开发者ID:ingydotnet,项目名称:tiddlyweb,代码行数:27,代码来源:test_recipe.py


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