Exemple #1
0
def do_action_bg(job_object):
    "deserializes info from gearman, finds action and processes"
    try: 
        global db
        if not db:
            # Have one global connection to the DB across app
            log.debug("in actions db get bg")
            memcache_cache = MemcacheCache(options.memcached_servers)
            db = model.get_database(cache=memcache_cache)
        db.session()
        g = globals()
        args = json.loads(job_object.arg)
        log.debug('in do_action_bg %s' % args)
        if 'action' in args and g.has_key(args['action']):
            log.debug('calling action = %s for args=%s' % (args['action'],args))
            g[args['action']](args)
        elif 'action' in args:
            log.debug('calling action 2 = %s for args=%s' % (args['action'],args))
            check_subscribers(args)
        else:
            log.error('whoops, that didnt work %s' % (args))
        db.session.close()
    except:
        logging.error("Error in gearman task do_action_bg:  %s" % traceback.print_exc())
        return -1
Exemple #2
0
 def __init__(self):
     # setup demisauce server config
     options.site_root = SITE_ROOT
     
     memcache_cache = MemcacheCache(options.memcached_servers)
     # Have one global connection to the DB across app
     self.db = model.get_database(cache=memcache_cache)
     log.debug("gearman_servers = %s" % options.gearman_servers)
Exemple #3
0
 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)
Exemple #4
0
"""
-s means don't capture stdout, send to terminal
::
    python test.py --config=nose.cfg demisauce/tests/test_models.py:test_site -s
"""
import windmill
import nose
import logging
import os
import tornado
from tornado.options import options, define
import demisauce.appbase
import demisaucepy.options
from demisaucepy.cache import DummyCache, MemcacheCache


TEST_ROOT = os.path.dirname(os.path.realpath(__file__))
config_file = os.path.realpath(TEST_ROOT + '/dev.conf' )
tornado.options.parse_command_line([0,"--config=%s" % config_file, '--logging=debug'])

# turn down Nose
nose_logger = logging.getLogger('nose')
nose_logger.setLevel(logging.ERROR)

memcache_cache = MemcacheCache(options.memcached_servers)

# Have one global connection to the DB across app
from demisauce import model
db = model.get_database(cache=memcache_cache)

nose.main()