In code that is called via web request you can use code like the below to retrieve a tiddler from the store. The Server Request Model establishes a store reference named tiddlyweb.store in the environ.
from tiddlyweb.model.tiddler import Tiddler

store = environ['tiddlyweb.store']

tiddler = Tiddler(title, bag)
tiddler.revision = revision # N.B.: revision 0 is HEAD
tiddler = store.get(tiddler)


When the code is not initiated by a web request, the caller must establish the store.
from tiddlyweb.store import Store
from tiddlyweb.config import config

store = Store(config['server_store'][0], config['server_store'][1], environ={})


Retrieving Tiddlers From Bag or Recipe


from tiddlyweb.model.bag import Bag
from tiddlyweb.model.recipe import Recipe
from tiddlyweb.store import Store
from tiddlyweb import control
from tiddlyweb.config import config


# set up environment
env = { 'tiddlyweb.config': config }
store = Store(config['server_store'][0], env)

# retrieve tiddlers from bag
bag_name = 'foo'
bag = Bag(bag_name)
bag = store.get(bag)
tiddlers = store.list_bag_tiddlers(bag)

# retrieve tiddlers from recipe
recipe_name = 'bar'
recipe = Recipe(recipe_name)
recipe = store.get(recipe)
tiddlers = control.get_tiddlers_from_recipe(recipe, env)

# In both the above cases the tiddlers returns have not been populated with data
# from the store. To do that do this:
for tiddler in tiddlers:
    tiddler = store.get(tiddler)
    # do something with the tiddler