Example #1
0
File: repo.py Project: banjin/code
    def temp_dir(self):
        if self._temp_dir:
            return self._temp_dir

        # TODO: move to Jagare
        pulltmp = os.path.join(get_tmpdir(), "pulltmp")
        if not os.path.exists(pulltmp):
            os.makedirs(pulltmp)
        worktree = tempfile.mkdtemp(dir=pulltmp)
        self._temp_dir = worktree
        return worktree
Example #2
0
    def temp_dir(self):
        if self._temp_dir:
            return self._temp_dir

        # TODO: move to Jagare
        pulltmp = os.path.join(get_tmpdir(), "pulltmp")
        if not os.path.exists(pulltmp):
            os.makedirs(pulltmp)
        worktree = tempfile.mkdtemp(dir=pulltmp)
        self._temp_dir = worktree
        return worktree
Example #3
0
# coding: utf-8

import os
from os.path import join
import logging
logging.getLogger().setLevel(logging.DEBUG)
from mako.lookup import TemplateLookup
from mako import exceptions
from code.config import CODE_DIR, MAKO_FS_CHECK
from code.libs.permdir import get_tmpdir
from code.libs.import_obj import import_obj


MAKO_CACHE_DIR = join(get_tmpdir(), "tmp_mako_0606", "mako_cache")

c = import_obj("c")
request = import_obj("request")

code_templates = TemplateLookup(
        directories=CODE_DIR + '/templates',
        module_directory=MAKO_CACHE_DIR,
        input_encoding='utf8',
        output_encoding='utf8',
        encoding_errors='ignore',
        default_filters=['h'],
        filesystem_checks=MAKO_FS_CHECK,
        imports = ["from code.libs.tplhelpers import static"]
)

def serve_template(uri, **kwargs):
    _t = code_templates.get_template(str(uri))
Example #4
0
File: web.py Project: banjin/code
 def __init__(self, *args, **kwargs):
     SessionPublisher.__init__(self, *args, **kwargs)
     display = 'html' if os.environ.get('DOUBAN_PRODUCTION') else 'plain'
     self.configure(DISPLAY_EXCEPTIONS=display,
                    UPLOAD_DIR=get_tmpdir() + '/upload/')
Example #5
0
# coding: utf-8

import os
from os.path import join
import logging
logging.getLogger().setLevel(logging.DEBUG)
from mako.lookup import TemplateLookup
from mako import exceptions
from code.config import CODE_DIR, MAKO_FS_CHECK
from code.libs.permdir import get_tmpdir
from code.libs.import_obj import import_obj

MAKO_CACHE_DIR = join(get_tmpdir(), "tmp_mako_0606", "mako_cache")

c = import_obj("c")
request = import_obj("request")

code_templates = TemplateLookup(
    directories=CODE_DIR + '/templates',
    module_directory=MAKO_CACHE_DIR,
    input_encoding='utf8',
    output_encoding='utf8',
    encoding_errors='ignore',
    default_filters=['h'],
    filesystem_checks=MAKO_FS_CHECK,
    imports=["from code.libs.tplhelpers import static"])


def serve_template(uri, **kwargs):
    _t = code_templates.get_template(str(uri))
    if 'self' in kwargs: