Example #1
0
def mselect(command, tiddlers):
    commands = command.split(MSELECT_SEPARATOR)
    results = []
    for command in commands:
        func = select_parse(command)
        results.extend(func(tiddlers))
    return results
Example #2
0
def mselect(command, tiddlers,environ=DEFAULT_ENVIRON):
    commands = command.split(environ['tiddlyweb.config']['mselect.separator'])
    # un_generate the tiddlers so we can use the list multiple times
    tiddlers = list(tiddlers)
    for command in commands:
        func = select_parse(command)
        for tiddler in func(tiddlers):
            yield tiddler
    return
    def mselect(command, entities, environ=None):
        global separator
        if environ:
            try:
                separator = environ['tiddlyweb.config']['mselect.separator']
            except (TypeError, KeyError):
                separator = MSELECT_SEPARATOR
        else:
            separator = config.get('mselect.separator', MSELECT_SEPARATOR)

        commands = command.split(separator)
        try:
            parsed_commands = [select_parse(command) for command in commands]
        except ValueError, exc:
            raise FilterError('malformed filter: %s' % exc)
Example #4
0
def recent(environ, start_response):
    bag_name = environ['tiddlyweb.query'].get('bag', [None])[0]
    recipe_name = environ['tiddlyweb.query'].get('recipe', [None])[0]
    since = environ['tiddlyweb.query'].get('since', [None])[0]

    store = environ['tiddlyweb.store']
    tiddlers = []
    title_string = "nothing"
    if recipe_name:
        recipe = Recipe(recipe_name)
        recipe = store.get(recipe)
        tiddlers = control.get_tiddlers_from_recipe(recipe, environ)
        title_string = 'recipe %s' % recipe_name
    if bag_name:
        bag = store.get(Bag(bag_name))
        tiddlers = bag.list_tiddlers()
        title_string = 'bag %s' % bag_name
    matching_tiddlers = []
    if since:
        modified_string = since
    else:
        time_object = datetime.utcnow() - timedelta(30)
        modified_string = unicode(time_object.strftime('%Y%m%d%H%M%S'))

    def reify_revision(tiddler, revision_id):
        revision = Tiddler(tiddler.title, tiddler.bag)
        revision.revision = revision_id
        return store.get(revision)

    selector = select_parse('modified:>%s' % modified_string)
    tiddlers = [store.get(tiddler) for tiddler in tiddlers]
    tiddlers = selector(tiddlers)
    for tiddler in tiddlers:
        revisions = [reify_revision(tiddler, id) for id
                in store.list_tiddler_revisions(tiddler)]
        matching_tiddlers.extend(selector(revisions))

    tiddlers = sort_by_attribute('modified', matching_tiddlers, reverse=True)

    environ['tiddlyweb.title'] = 'Recent changes for %s' % title_string

    return ['%s:%s:%s:%s<br/>' %
            (tiddler.title, tiddler.revision, tiddler.modified, tiddler.modifier)
            for tiddler in tiddlers]