def synchronize_url(): url = utils.site_url('/site.js') url = 'http://localhost/GalleryMetadata/site.js' # sys.stdout.write('\n\n') #sys.stdout.write('Downloading from: ' + url + '\n'); result = urlfetch.fetch(url); if result.status_code == 200: contents = result.content synchronize_common(contents)
def dispatch_secret(path): jt.access = 'secret' # modes res = re.match(r'^([^/]+)/('+'|'.join(modes.keys())+')/([^/]*)$', path) if res: url, mode, method = res.groups() jt.site = db.get_site(secret_url=url) if not jt.site or jt.site.deleted: return no_site(url) if jt.site.public_url: return web.seeother(utils.site_url()+mode+'/'+method) return dispatch_mode(mode, method) # pages res = re.match(r'^([^/]+)/(.*)', path) if res: url, page = res.groups() # make all secret urls lowercase if not url.islower(): return web.seeother('/%s/%s' % (url.lower(), page)) jt.site = db.get_site(secret_url=url) if not jt.site or jt.site.deleted: return no_site(url) if page != page.replace(' ', '_'): return web.seeother(utils.page_url(page)+web.ctx.query) if jt.site.public_url: return web.seeother(utils.site_url()+page) return dispatch_page(page) return web.notfound()
def dispatch_secret(path): jt.access = 'secret' # modes res = re.match(r'^([^/]+)/(' + '|'.join(modes.keys()) + ')/([^/]*)$', path) if res: url, mode, method = res.groups() jt.site = db.get_site(secret_url=url) if not jt.site or jt.site.deleted: return no_site(url) if jt.site.public_url: return web.seeother(utils.site_url() + mode + '/' + method) return dispatch_mode(mode, method) # pages res = re.match(r'^([^/]+)/(.*)', path) if res: url, page = res.groups() # make all secret urls lowercase if not url.islower(): return web.seeother('/%s/%s' % (url.lower(), page)) jt.site = db.get_site(secret_url=url) if not jt.site or jt.site.deleted: return no_site(url) if page != page.replace(' ', '_'): return web.seeother(utils.page_url(page) + web.ctx.query) if jt.site.public_url: return web.seeother(utils.site_url() + page) return dispatch_page(page) return web.notfound()
def synchronize(): url = utils.site_url('/site.js') url = 'E:\\Gallery\\LiveImages\\site.js' url = 'E:\\GalleryMetadata\\site.js' # sys.stdout.write('\n\n') #sys.stdout.write('Downloading from: ' + url + '\n'); #result = urlfetch.fetch(url); #if result.status_code == 200: # contents = result.content # #sys.stdout.write(contents+ '\n\n') with open(url, "r") as myfile: contents = myfile.read() myfile.close() synchronize_common(contents)
def get_sites(email): query = """SELECT public_url, secret_url, title, updated FROM sites s WHERE email = $email AND deleted = false ORDER BY updated DESC""" sites = web.query(query, vars=locals()) sites = list(sites) for s in sites: s.url = utils.site_url(s) out = web.utils.iterbetter(iter(sites)) out.__len__ = len(sites) out.__list__ = sites return out
def get_site(**vars): if vars is None: vars = {} vars = dict([(c, str(v)) for (c, v) in vars.items()]) def pfix(s): if s == 'id': return 's.id' else: return s where_clause = ' AND '.join('%s = $%s' % (pfix(k), k) for k in vars.keys()) query = """SELECT s.*, to_char(s.updated, 'YYYY-MM-DD"T"HH24:MI:SSZ') as atom_updated FROM sites s WHERE %s LIMIT 1 """ % where_clause d = web.query(query, vars=vars) d = (d and d[0]) or None if d: d.url = utils.site_url(d) return d
def change_public_url(url): url = url.strip() site_id = jt.site.id web.update('sites', where='id=$site_id', public_url=url, vars=locals()) jt.site.public_url = url jt.site.url = utils.site_url(jt.site)