Пример #1
0
def get_thing(name, type):
    site = get_site()
    try:
        thing = tdb.withName(name, site)
        if thing.type.id == type.id:
            fill_backreferences(thing)
            return thing
    except tdb.NotFound:
        pass
    return None
Пример #2
0
def get_thing(name, type):
    site = get_site()
    try:
        thing = tdb.withName(name, site)
        if thing.type.id == type.id:
            fill_backreferences(thing)
            return thing
    except tdb.NotFound:
        pass
    return None
Пример #3
0
def new_links(page, links):
    # for links thing: parent=page, type=linkstype
    site = page.parent
    path = page.name
    d = {'site': site, 'path': path, 'links': list(links)}
    
    try:
        backlinks = tdb.withName("links", page)
        backlinks.setdata(d)
        backlinks.save()
    except tdb.NotFound:
        backlinks = tdb.new("links", page, get_links_type(), d)
        backlinks.save()
Пример #4
0
def new_links(page, links):
    # for links thing: parent=page, type=linkstype
    site = page.parent
    path = page.name
    d = {'site': site, 'path': path, 'links': list(links)}

    try:
        backlinks = tdb.withName("links", page)
        backlinks.setdata(d)
        backlinks.save()
    except tdb.NotFound:
        backlinks = tdb.new("links", page, get_links_type(), d)
        backlinks.save()
Пример #5
0
 def new_version(page):
     print "new_version", page.name
     d = dict([(k, remap(v)) for k, v in page.d.items()])
     try:
         p = tdb.withName(page.name, site)
         p.setdata(d)
         
         # careful about type/type
         if page.type.id != page.id:
             p.type = remap(page.type)
     except tdb.NotFound:
         p = tdb.new(page.name, site, remap(page.type), d)
     
     p.save()
     return p.id