Example #1
0
    def _open_client (self, location):
        """Open 'location' (a (hostname, port_number) tuple) as a ZEO
        ClientStorage, and then open a ZODB database around that.  Return
        a (database, connection) tuple.
        
        We override dulcinea.database.ObjectDatabase._open_client to support
        username/password.
        """
        host, port = location
        if host == "":
            # If the specified hostname is the empty string, then
            # 'localhost' is used.
            location = ('localhost', port)
            
        site_config = get_config()
        username = site_config.get(self.site, 'zeo-username', fallback='')
        password = site_config.get(self.site, 'zeo-password', fallback='')

        # we use QonClientStorage instead of ClientStorage to:
        #  1. workaround ClientStorage's cache_size bug
        #  2. enable cache instrumentation (if qon.local.CACHE_INSTRUMENTATION is True)
        from qon.cache_logging import QonClientStorage        
        self.storage = QonClientStorage(location,
            var='/var/tmp',
            wait=0,
            cache_size=150*MB,
            username=username,
            password=password)
        
        db = DB(self.storage)
        
        return (db, db.open())
Example #2
0
def _log_name(s):
    """Return path to log file for filename s."""
    from dulcinea import site_util
    config = site_util.get_config()
    site = os.environ.get('SITE', 'qon')
    return os.path.join(config.defaults().get('log-directory'),
        site,
        s)
Example #3
0
 def __init__(self, group, root_dir=None):
     GenericDB.__init__(self)
     self.group = group
     self.quota = self._initial_quota
     self.dirs = QonDir()
     
     if root_dir is None:
         site = os.environ.get('SITE')
         if site:
             config = site_util.get_config()
             root_dir = config.get(site, 'file-store',
                 fallback='/tmp')
         else:
             root_dir = '/tmp'
     self.root_dir = root_dir
Example #4
0
#!/usr/bin/python2.4
"""
$Id: cron-hourly.py,v 1.7 2007/02/03 23:52:50 alex Exp $

Various regular maintenance.
"""
import os, time
from dulcinea import site_util
from qon.base import open_database, get_database, close_database, \
    get_session_manager, get_user_database, get_list_database, \
    transaction_commit, get_group_database
import smtplib
from qon import local

site = 'qon'
config = site_util.get_config()

def update_group_karma():
    group_db = get_group_database()
    for group_id, group in group_db.root.iteritems():
        group._calc_karma_score()
        transaction_commit(None, 'GroupKarmaUpdate')

def update_stats():
    """Update the expensive site-wide stats."""
    list_db = get_list_database()

    list_db.group_stats_force_update()
    transaction_commit(None, 'GroupStatsUpdate')

    list_db.user_stats_force_update()
Example #5
0
    obj = qon.util.get_oid(d.get('oid'))
    if t=='Discussion':
        return obj.blog.ihb
    if t=='Wikipage':
        return obj.wiki.group
    if t=='Group':
        return obj
    if t=='Poll':
        return obj.container.ihb
    if t=='DiscussionComment':
        return obj.parent_blogitem.blog.ihb
    return None    
    

# A "do-nothing" search engine
# searchengine = SearchEngine()

# Lupy
# import qon.search_lupy
# searchengine = qon.search_lupy.SearchLupy("/www/var/qon_lupy")

# Lucene for xmlrpc -- get address from site.conf file
import qon.search_lucene
from dulcinea.site_util import get_config
import os
site_config = get_config()
site = os.environ.get('SITE', None)
lucene_address = site_config.get(site, 'lucene-address', fallback='')
searchengine = qon.search_lucene.SearchLucene(lucene_address)
# ----------------------------------------------------------------------