Пример #1
0
def custom_handler(accept, delay=DELAY, encoding_ovrride=False):
    handlers = default_handlers[:]
    handlers.append(crawler.EncodingFixHandler(encoding_ovrride))
    handlers.append(crawler.ContentNegociationHandler(accept))
    handlers.append(crawler.SQliteCacheHandler(delay))

    return build_opener(*handlers)
Пример #2
0
def custom_handler(accept, delay=DELAY):
    handlers = default_handlers[:]
    handlers.append(crawler.ContentNegociationHandler(accept))
    handlers.append(crawler.SQliteCacheHandler(delay))

    return build_opener(*handlers)
Пример #3
0

class BaseHandler(webapp.RequestHandler):

  def base_path(self):
    return self.request.path[:-len(self.__class__.PATH)]

  def render(self, template_name, request_values={}):
    home = os.path.dirname(__file__) 
    lookup = TemplateLookup(directories=[os.path.join(home, 'templates')])
    template = lookup.get_template('%s.mako.html' % template_name)
    template_values = {
      'application_name': self.request.environ['APPLICATION_ID'],
      'base_path': self.base_path(),
      'request': self.request,
      }
    template_values.update(request_values)
    self.response.out.write(template.render(**template_values))


class DefaultHandler(BaseHandler):
  PATH = '/'
  def get(self):
    self.render('helloworld', { 'user': '******' })


if __name__ == '__main__':
  handlers = []
  handlers.append(('.*', DefaultHandler))
  wsgiref.handlers.CGIHandler().run(webapp.WSGIApplication(handlers, debug=_DEBUG))
Пример #4
0
from google.appengine.ext import webapp

# setup the environment
from common.appenginepatch.aecmd import setup_env
setup_env(manage_py_env=True)
from dojango.conf import settings

# creating a handler structure for the zip-files within the release folder
release_dir = '%s/release/%s' % (settings.BASE_MEDIA_ROOT, settings.DOJO_VERSION)
handlers = []
for zip_file in os.listdir(release_dir):
    if zip_file.endswith(".zip"):
        module = os.path.splitext(zip_file)[0]
        handler = [os.path.join(release_dir, zip_file)]
        handlers.append(handler)

class FlushCache(webapp.RequestHandler):
    """
    Handler for flushing the whole memcache instance.
    """
    from google.appengine.ext.webapp.util import login_required
    @login_required 
    def get(self):
        from google.appengine.api import memcache
        from google.appengine.api import users
        if users.is_current_user_admin():
            stats = memcache.get_stats()
            memcache.flush_all()
            self.response.out.write("Memcache successfully flushed!<br/>")
            if stats:
Пример #5
0
from google.appengine.ext import webapp

# setup the environment
from common.appenginepatch.aecmd import setup_env
setup_env(manage_py_env=True)
from dojango.conf import settings

# creating a handler structure for the zip-files within the release folder
release_dir = '%s/release/%s' % (settings.BASE_MEDIA_ROOT, settings.DOJO_VERSION)
handlers = []
for zip_file in os.listdir(release_dir):
    if zip_file.endswith(".zip"):
        module = os.path.splitext(zip_file)[0]
        handler = [os.path.join(release_dir, zip_file)]
        handlers.append(handler)

class FlushCache(webapp.RequestHandler):
    """
    Handler for flushing the whole memcache instance.
    """
    from google.appengine.ext.webapp.util import login_required
    @login_required 
    def get(self):
        from google.appengine.api import memcache
        from google.appengine.api import users
        if users.is_current_user_admin():
            stats = memcache.get_stats()
            memcache.flush_all()
            self.response.out.write("Memcache successfully flushed!<br/>")
            if stats: