def __init__(self): template_path = os.path.join(os.path.dirname(__file__), "demisauce/views") # Have one global connection to the DB across app cache_setup.load_cache() memcache_cache = MemcacheCache(options.memcached_servers) self.db = model.get_database(cache=memcache_cache) log.debug("gearman_servers = %s" % options.gearman_servers) settings = { "title": u"Local 151", "template_path": template_path, "static_path":os.path.join(os.path.dirname(__file__), "demisauce/static"), "xsrf_cookies": False, "cookie_secret":"32oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=", "login_url":"/user/signin", "redis_host":options.redis_host, "demisauce_url":options.demisauce_url, "asset_url":options.asset_url, "oauth_callback":("%saccount/" % options.base_url), "debug":options.debug, "base_url":options.base_url, "twitter_consumer_key":options.twitter_consumer_key, "twitter_consumer_secret":options.twitter_consumer_secret, "facebook_api_key":options.facebook_api_key, "facebook_secret":options.facebook_secret, "sqlalchemy_default_url":options.sqlalchemy_default_url, "sqlalchemy_default_echo":options.sqlalchemy_default_echo, #"template_path":template_path, }## "ui_modules": {"Entry": EntryModule}, from demisauce import controllers _handlers = [] + controllers._controllers from demisauce.controllers import account, home, dashboard, template,\ admin, site, api, service _handlers += account._controllers + \ home._controllers + dashboard._controllers + template._controllers + \ admin._controllers + site._controllers + api._controllers + \ service._controllers from demisauce.controllers import CustomErrorHandler self.error_handler = CustomErrorHandler jinja_env = Jinja2Environment(loader=jinja2.FileSystemLoader(template_path), extensions=[FragmentCacheExtension]) #jinja_env.fragment_cache = DummyCache() jinja_env.fragment_cache = memcache_cache # custom filters etc jinja_env.filters.update(helpers._filters) settings.update({"jinja2_env":jinja_env}) # start web app tornado.web.Application.__init__(self, _handlers, **settings)
def __init__(self, settings): super(DemisauceRegistry, self).__init__(settings=settings) api_key = settings.registry_config['api_key'] url = settings.registry_config['source'] appname = settings.registry_config['appname'] try: dsconfig.CFG['demisauce.apikey'] = api_key or 'a95c21ee8e64cb5ff585b5f9b761b39d7cb9a202' dsconfig.CFG['demisauce.url'] = url or 'http://localhost:4951' dsconfig.CFG['demisauce.appname'] = appname or 'hudsucker' dsconfig.CFG['cacheservers'] = settings.memcached['servers'].replace(',',';') cache_setup.load_cache(cachetype='memcache') except Exception, detail: print("WARNING: Can't connect to demisauce: %s." % detail)
def main(): print("Running Worker .....") print("options.logging = %s" % options.logging) from demisaucepy import cache_setup cache_setup.load_cache() #global app #app = AppBase() logging.info("site_root = %s" % options.site_root) logging.info("smtp servers = %s" % options.smtp_server) logging.info("cache servers = %s" % options.memcached_servers) logging.info("gearman servers 2 = %s" % (options.gearman_servers)) logging.error("where does this go in supervisord?") worker = GearmanWorker(options.gearman_servers) worker.register_function("email_send", emailer.email_send) worker.register_function("image_resize", assets.image_resize) worker.register_function("echo", echo) from demisauce.model import actions actions.register_workers(worker) worker.work()
from unittest import TestCase import string import tornado from tornado.options import options, define, enable_pretty_logging import demisaucepy.options log = logging.getLogger("demisaucepy") TEST_ROOT = os.path.dirname(os.path.realpath(__file__)) config_file = os.path.realpath(TEST_ROOT + '/../../../demisauce/dev.conf' ) tornado.options.parse_command_line([0,"--config=%s" % config_file, '--logging=debug']) log.debug("about to setup cache = %s" % options.demisauce_cache) log.debug("about to demisauce_url = %s" % options.demisauce_url) log.debug("about to demisauce_api_key = %s" % options.demisauce_api_key) from demisaucepy import cache_setup cache_setup.load_cache(cachetype=options.demisauce_cache) import demisaucepy class TestDSBase(TestCase): """ Test base class """ def __init__(self, *args): self.url = options.demisauce_url TestCase.__init__(self, *args) __all__ = ['TestDSBase']