Example #1
0
 def get(self, user, alias, docname, format=None):
     lang=None; charset=None
     logging.info([user, alias, docname, lang, charset, format])
     if not alias:
         return self.not_found(self.request.uri)
     alias = api.find_alias(None, alias)
     if not docname:
         docname = alias.default_page
     elif docname.endswith('/'):
         docname += alias.default_leaf
     unid = "~%s/%s" % (alias.handle, docname)
     self.server._reload(alias)
     stat = self.server.stat(unid)
     if not format: format='html'
     if not stat:
         if stat.srcnfo:
             cache = model.BuildCache.all().ancestor(stat.srcnfo).get()
             if cache: cache.delete()
         pr = self.server.process(unid, format='rst')
         assert not pr.errors, map(lambda x:x.astext(),
                 pr.errors)
     cached = model.BuildCache.get_by_key_name(format,
                 stat.srcnfo)
     if cached:
         output = cached.output
     else:            
         output = self.server.publish(unid, format).output
         srcnfo = api.find_sourceinfo(alias, unid)
         model.BuildCache(key_name=format, 
                 output=output, parent=srcnfo).put()            
     return mediatype_for_extension(format), output
Example #2
0
 def get(self, doc_name, format, **params):
     if self.is_devhost():
         alias = api.find_alias(None,'BL Dev')
         assert alias, "BL Dev has not been initialized. "
     else:            
         alias = api.find_alias(None,'Blue Lines')
         assert alias, "Blue Lines has not been initialized. "
     if not doc_name:
         doc_name = alias.default_page
     elif doc_name.endswith('/'):
         doc_name += alias.default_leaf
     unid = "~%s/%s" % (alias.handle, doc_name)
     logger.info("StaticPage GET %s", unid)
     self.server._reload(alias)
     stat = self.server.stat(unid)
     if not format: format='html'
     if not stat:
         if stat.srcnfo:
             # clear cache
             cache = model.BuildCache.all().ancestor(stat.srcnfo).get()
             if cache: cache.delete()
         logger.info("StaticPage: %s needs (re)proc.", unid)
         # TODO: work in progress..
         #return self.multistep(API+'/process', self.request.uri)
         pr = self.server.process(unid, format='rst')
         assert not pr.errors, map(lambda x:x.astext(),
                 pr.errors)
     cached = model.BuildCache.get_by_key_name(format,
                 stat.srcnfo)
     if cached:
         output = cached.output
     else:                
         output = self.server.publish(unid, format).output
         srcnfo = api.find_sourceinfo(alias, unid)
         model.BuildCache(key_name=format, 
                 output=output, parent=srcnfo).put()            
     return mediatype_for_extension(format), output
Example #3
0
 def wrapper(self, user, v, alias=None, unid=None, *args, **qwds):
     if not isinstance(alias, model.alias.Alias):
         if alias:
             alias_id = alias
         elif unid:
             p = unid.find('/')
             alias_id = unid[1:p]
         else:
             raise ValueError, "Need alias_id or unid to initialize Alias kind. "
         alias = api.find_alias(None,alias_id)
         if not alias:
             new = qwds.get('new-alias', None)
             if not new or new.lower() not in ('yes', 'true'):
                 self.error(404)
                 return exception.NotFound("Alias %r" % alias_id)
             else:
                 alias = api.new_alias(user, alias_id)
     if unid:
         qwds.update(dict(unid=unid))
     return method(self, user, v, alias, *args, **qwds)
Example #4
0
    except:
        raise Exception, "Could not parse HTTP Authorization. "

    if authserv == 'gmail':
        if not dev:
            try:
                auth_token = get_google_authtoken('blue-lines', name, passwd)
            except exception.AuthError, e:
                logger.info("Got a failed login attempt for Google Accounts %r",
                        username)
                raise AuthError, ""
        obj = db.get(users.User(email=name).put())
        return api.new_or_existing(obj)

    elif authserv == 'alias':
        alias = api.find_alias(None,name)
        keys = (tuple(passwd.split(','))+2*('',))[0:3]
        if alias:
            access_key, process_key, update_key = keys
            if access_key != alias.access_key:
                raise AuthError, "Not authorized for alias"
            return alias
        else:
            pass # allow none-alias in server, but only for ~alias document
            return name, keys

    else:
        raise AuthError, ""


## Remote content utils
Example #5
0
 def get(self, user, v, id, handle):
     """
     List all or find one or any of kind Alias.
     """
     return api.find_alias(id, handle=handle)