def setUp(self): self.mojology = Mojology(config_object="mojology.tests.TestConfig") self.app = self.mojology.test_client() self.db = pymongo.Connection(TestConfig.MONGO_HOST, TestConfig.MONGO_PORT) self.coll = self.db[TestConfig.MONGO_DB][TestConfig.MONGO_COLLECTION] self.pagesize = TestConfig.MOJOLOGY_PAGESIZE self.cache = TestConfig.MOJOLOGY_COLLECTION_PREFIX self.layout = TestConfig.MOJOLOGY_LAYOUT self.coll.drop()
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <http://www.gnu.org/licenses/>. from mojology import Mojology import os, sys from werkzeug.wsgi import DispatcherMiddleware if len (sys.argv) > 1: cfg_file = os.path.realpath (sys.argv[1]) if not os.path.exists (cfg_file): cfg_file = None else: cfg_file = os.path.realpath (os.path.join (os.path.dirname (__file__), "local_settings.py")) if not os.path.exists (cfg_file): cfg_file = None app = Mojology (config_file = cfg_file) sites = {} for site in sys.argv[2:]: sapp = Mojology (config_file = os.path.realpath (site)) if not "MOJOLOGY_SITE_ROOT" in sapp.config: raise SyntaxError, "'%s' does not set MOJOLOGY_SITE_ROOT" % site sites[sapp.config['MOJOLOGY_SITE_ROOT']] = sapp.wsgi_app app.wsgi_app = DispatcherMiddleware (app.wsgi_app, sites) app.run ()
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <http://www.gnu.org/licenses/>. from mojology import Mojology import pymongo import os cfg_file = os.path.realpath( os.path.join(os.path.dirname(__file__), "local_settings.py")) if not os.path.exists(cfg_file): cfg_file = None m = Mojology(config_file=cfg_file) conn = pymongo.Connection(m.config['MONGO_HOST'], m.config['MONGO_PORT']) db = conn[m.config['MONGO_DB']] try: db.authenticate(m.config['MONGO_USER'], m.config['MONGO_PASS']) except: pass coll = db[m.config['MONGO_COLLECTION']] cache = m.config['MOJOLOGY_COLLECTION_PREFIX'] layout = m.config['MOJOLOGY_LAYOUT'] def mr(map_js, out): coll.map_reduce( map_js,