Ejemplo n.º 1
0
    def _update_links(self, links, tiddler):
        """
        Update the links database.
        """
        source = _tiddler_key(tiddler)

        warnings.simplefilter('error', MySQLdb.Warning)

        try:
            for link, space in set(links):
                if link is None:
                    link = ''
                if is_link(link):
                    target = link
                elif space:
                    if link:
                        target = '%s_public:%s' % (space, link)
                    else:
                        target = '@%s:' % space
                else:
                    target = '%s:%s' % (tiddler.bag, link)
                new_link = SLink(source, target)
                self.session.add(new_link)
                self.session.commit()
        except MySQLdb.Warning, exc:
            self.session.rollback()
            pass
    def _update_links(self, links, tiddler):
        """
        Update the links database.
        """
        source = _tiddler_key(tiddler)

        try:
            for link, space in links:
                if link is None:
                    link = ''
                if is_link(link):
                    target = link
                elif space:
                    target = '%s_public:%s' % (space, link)
                else:
                    target = '%s:%s' % (tiddler.bag, link)
                new_link = SLink(source, target)
                self.session.add(new_link)
                self.session.commit()
        except:
            self.session.rollback()
            raise
    def _update_links(self, links, tiddler):
        """
        Update the links database.
        """
        source = _tiddler_key(tiddler)

        config = self.environ.get('tiddlyweb.config', {})
        at_means_bag = config.get('links.at_means_bag', False)

        if MYSQL_PRESENT:
            warnings.simplefilter('error', MySQLdb.Warning)

        try:
            for link, space in set(links):
                if link is None:
                    link = ''
                if is_link(link):
                    target = link
                elif space:
                    if link:
                        if at_means_bag:
                            target = '%s:%s' % (space, link)
                        else:
                            target = '%s_public:%s' % (space, link)
                    else:
                        target = '@%s:' % space
                else:
                    target = '%s:%s' % (tiddler.bag, link)
                new_link = SLink(source, target)
                self.session.add(new_link)
                self.session.commit()
        except MySQLdb.Warning:
            self.session.rollback()
            pass
        except:
            self.session.rollback()
            raise
Ejemplo n.º 4
0
    links_manager = LinksManager(environ)

    try:
        links = getattr(links_manager, 'read_%s' % linktype)(host_tiddler)
    except AttributeError, exc:
        raise HTTP400('invalid links type: %s' % exc)

    if filters:
        tiddlers = Tiddlers(title=collection_title)
    else:
        tiddlers = Tiddlers(title=collection_title, store=store)
    tiddlers.link = link

    # continue over entries in database from previous format
    for link in links:
        if is_link(link):  # external link
            continue
        else:
            container, title = link.split(':', 1)
            if not title:  # plain space link
                continue
            elif title:
                if container != bag_name:
                    if container.endswith('_public'):
                        try:
                            recipe = Recipe(container)
                            recipe = store.get(recipe)
                            tiddler = Tiddler(title)
                            tiddler.recipe = container
                            bag = determine_bag_from_recipe(recipe, tiddler,
                                    environ)
Ejemplo n.º 5
0
            tiddler.title, exc))

    links_manager = LinksManager(environ)

    try:
        links = getattr(links_manager, 'read_%s' % linktype)(tiddler)
    except AttributeError, exc:
        raise HTTP400('invalid links type: %s' % exc)

    if filters:
        tiddlers = Tiddlers(title=title)
    else:
        tiddlers = Tiddlers(title=title, store=store)

    for link in links:
        if is_link(link):
            tiddler = Tiddler(link, 'temp')
            tiddler.text = link
            tiddler.fields['_canonical_uri'] = link
            tiddler.store = store
        else:
            container, title = link.split(':', 1)
            if title:  # skip space links for now
                try:
                    recipe = Recipe(container)
                    recipe = store.get(recipe)
                    bag = determine_bag_from_recipe(recipe, tiddler, environ)
                    bag_name = bag.name
                except StoreError:
                    bag_name = container
                tiddler = Tiddler(title, bag_name)