示例#1
0
import os
import posixpath
import re
from time import time
from wsgiref.handlers import format_date_time

from olympia.constants import base

from services.utils import log_configure, log_exception, mypool
from services.utils import settings, user_media_path, user_media_url

# This has to be imported after the settings (utils).
from django_statsd.clients import statsd

# Configure the log.
log_configure()


class ThemeUpdate(object):
    def __init__(self, locale, id_, qs=None):
        self.conn, self.cursor = None, None
        self.from_gp = qs == 'src=gp'
        self.data = {
            'locale': locale,
            'id': id_,
            # If we came from getpersonas.com, then look up by `persona_id`.
            # Otherwise, look up `addon_id`.
            'primary_key': 'persona_id' if self.from_gp else 'addon_id',
            'atype': base.ADDON_PERSONA,
            'row': {}
        }
示例#2
0
import posixpath
import re
from time import time
from wsgiref.handlers import format_date_time

from olympia.constants import base

from services.utils import (
    get_cdn_url, log_configure, log_exception, mypool, settings,
    user_media_url)

# This has to be imported after the settings (utils).
from django_statsd.clients import statsd

# Configure the log.
log_configure()


class ThemeUpdate(object):

    def __init__(self, locale, id_, qs=None):
        self.from_gp = qs == 'src=gp'
        self.addon_id = id_
        self.cursor = mypool.connect().cursor()

    def get_headers(self, length):
        return [('Cache-Control', 'public, max-age=86400'),
                ('Content-Length', str(length)),
                ('Content-Type', 'application/json'),
                ('Expires', format_date_time(time() + 86400)),
                ('Last-Modified', format_date_time(time()))]