def hash_passwords(): from infogami.core import auth tuser = db.get_type(ctx.site, 'type/user') users = tdb.Things(parent=ctx.site, type=tuser).list() for u in users: try: preferences = u._c('preferences') except: # setup preferences for broken accounts, so that they can use forgot password. preferences = db.new_version(u, 'preferences', db.get_type(ctx.site,'type/thing'), dict(password='')) preferences.save() if preferences.password: auth.set_password(u, preferences.password)
def GET(self, site, path): # @@ fix later return [] # TODO: (cclauss) unreachable code... links = db.Things(type=db.get_type(site, 'type/page'), parent=site, links=path) return render.backlinks(links)
def GET(self, site, path): #@@ fix later return [] links = tdb.Things(type=db.get_type(site, 'type/page'), parent=site, links=path) return render.backlinks(links)
def hash_passwords(): from infogami.core import auth tuser = db.get_type(ctx.site, 'type/user') users = tdb.Things(parent=ctx.site, type=tuser).list() for u in users: try: preferences = u._c('preferences') except: # setup preferences for broken accounts, so that they can use forgot password. preferences = db.new_version(u, 'preferences', db.get_type(ctx.site, 'type/thing'), dict(password='')) preferences.save() if preferences.password: auth.set_password(u, preferences.password)
def upgrade_types(): from infogami.core.db import _create_type, tdbsetup tdbsetup() type = db.get_type(ctx.site, "type/type") types = tdb.Things(parent=ctx.site, type=type) types = [ t for t in types if 'properties' not in t.d and 'is_primitive' not in t.d ] primitives = dict(int='type/int', integer='type/int', string='type/string', text='type/text') newtypes = {} for t in types: properties = [] backreferences = [] print(t, t.d, file=web.debug) if t.name == 'type/site': continue for name, value in t.d.items(): p = web.storage(name=name) typename = web.lstrips(value, "thing ") if typename.startswith('#'): typename, property_name = typename.lstrip('#').split('.') p.type = db.get_type(ctx.site, typename) p.property_name = property_name backreferences.append(p) continue if typename.endswith('*'): typename = typename[:-1] p.unique = False else: p.unique = True if typename in primitives: typename = primitives[typename] p.type = db.get_type(ctx.site, typename) properties.append(p) _create_type(ctx.site, t.name, properties, backreferences)
def upgrade_types(): from infogami.core.db import _create_type, tdbsetup tdbsetup() type = db.get_type(ctx.site, "type/type") types = tdb.Things(parent=ctx.site, type=type) types = [t for t in types if 'properties' not in t.d and 'is_primitive' not in t.d] primitives = dict(int='type/int', integer='type/int', string='type/string', text='type/text') newtypes = {} for t in types: properties = [] backreferences = [] print >> web.debug, t, t.d if t.name == 'type/site': continue for name, value in t.d.items(): p = web.storage(name=name) typename = web.lstrips(value, "thing ") if typename.startswith('#'): typename, property_name = typename.lstrip('#').split('.') p.type = db.get_type(ctx.site, typename) p.property_name = property_name backreferences.append(p) continue if typename.endswith('*'): typename = typename[:-1] p.unique = False else: p.unique = True if typename in primitives: typename = primitives[typename] p.type = db.get_type(ctx.site, typename) properties.append(p) _create_type(ctx.site, t.name, properties, backreferences)
def GET(self, path): i = web.input(v=None, t=None) if not web.ctx.site.can_write(path): return render.permission_denied(web.ctx.fullpath, "Permission denied to edit " + path + ".") if i.v is not None and safeint(i.v, None) is None: raise web.seeother(web.changequery(v=None)) p = db.get_version(path, i.v) or db.new_version(path, types.guess_type(path)) if i.t: type = db.get_type(i.t) if type is None: add_flash_message('error', 'Unknown type: ' + i.t) else: p.type = type return render.editpage(p)
def get_type(type_name): site = get_site() return db.get_type(site, type_name)
def get_links_type(): linkstype = db.get_type('links') or db.new_type('links') linkstype.save() return linkstype
def GET(self, site, path): # @@ fix later return [] links = tdb.Things(type=db.get_type(site, "type/page"), parent=site, links=path) return render.backlinks(links)