示例#1
0
    def __init__(self, force=False):
        engine = g.dbm.get_engine('email')
        self.metadata = make_metadata(engine)
        self.queue_table = mail_queue(self.metadata)
        indices = [
            index_str(self.queue_table, "date", "date"),
            index_str(self.queue_table, 'kind', 'kind')
        ]
        create_table(self.queue_table, indices)

        self.opt_table = opt_out(self.metadata)
        indices = [index_str(self.opt_table, 'email', 'email')]
        create_table(self.opt_table, indices)

        self.track_table = sent_mail_table(self.metadata)
        self.reject_table = sent_mail_table(self.metadata, name="reject_mail")

        def sent_indices(tab):
            indices = [
                index_str(tab, 'to_addr', 'to_addr'),
                index_str(tab, 'date', 'date'),
                index_str(tab, 'ip', 'ip'),
                index_str(tab, 'kind', 'kind'),
                index_str(tab, 'fullname', 'fullname'),
                index_str(tab, 'account_id', 'account_id'),
                index_str(tab, 'msg_hash', 'msg_hash'),
            ]

        create_table(self.track_table, sent_indices(self.track_table))
        create_table(self.reject_table, sent_indices(self.reject_table))
示例#2
0
    def __init__(self, force=False):
        engine = g.dbm.get_engine("email")
        self.metadata = make_metadata(engine)
        self.queue_table = mail_queue(self.metadata)
        indices = [index_str(self.queue_table, "date", "date"), index_str(self.queue_table, "kind", "kind")]
        create_table(self.queue_table, indices)

        self.opt_table = opt_out(self.metadata)
        indices = [index_str(self.opt_table, "email", "email")]
        create_table(self.opt_table, indices)

        self.track_table = sent_mail_table(self.metadata)
        self.reject_table = sent_mail_table(self.metadata, name="reject_mail")

        def sent_indices(tab):
            indices = [
                index_str(tab, "to_addr", "to_addr"),
                index_str(tab, "date", "date"),
                index_str(tab, "ip", "ip"),
                index_str(tab, "kind", "kind"),
                index_str(tab, "fullname", "fullname"),
                index_str(tab, "account_id", "account_id"),
                index_str(tab, "msg_hash", "msg_hash"),
            ]

        create_table(self.track_table, sent_indices(self.track_table))
        create_table(self.reject_table, sent_indices(self.reject_table))
示例#3
0
    def __init__(self, force = False):
        engine = g.dbm.get_engine('email')
        self.metadata = make_metadata(engine)
        self.queue_table = mail_queue(self.metadata)
        indices = [index_str(self.queue_table, "date", "date"),
                   index_str(self.queue_table, 'kind', 'kind')]
        create_table(self.queue_table, indices)

        self.opt_table = opt_out(self.metadata)
        indices = [index_str(self.opt_table, 'email', 'email')]
        create_table(self.opt_table, indices)

        self.track_table = sent_mail_table(self.metadata)
        self.reject_table = sent_mail_table(self.metadata, name = "reject_mail")

        def sent_indices(tab):
            indices = [index_str(tab, 'to_addr', 'to_addr'),
                       index_str(tab, 'date', 'date'),
                       index_str(tab, 'ip', 'ip'),
                       index_str(tab, 'kind', 'kind'),
                       index_str(tab, 'fullname', 'fullname'),
                       index_str(tab, 'account_id', 'account_id'),
                       index_str(tab, 'msg_hash', 'msg_hash'),
                       ]

        create_table(self.track_table, sent_indices(self.track_table))
        create_table(self.reject_table, sent_indices(self.reject_table))
示例#4
0
def make_change_tables(force=False):
    metadata = make_metadata(change_engine)
    table = change_table(metadata)
    indices = [
        index_str(table, 'fullname', 'fullname'),
        index_str(table, 'date', 'date')
    ]
    create_table(table, indices, force=force)
    return table
示例#5
0
def make_change_tables(force = False):
    metadata = make_metadata(change_engine)
    table = change_table(metadata)
    indices = [
        index_str(table, 'fullname', 'fullname'),
        index_str(table, 'date', 'date')
        ]
    create_table(table, indices, force = force)
    return table
示例#6
0
def make_query_queue_table():
    metadata = make_metadata(query_queue_engine)
    table = sa.Table(settings.DB_APP_NAME + '_query_queue', metadata,
                     sa.Column('iden', sa.String, primary_key=True),
                     sa.Column('query', sa.Binary),
                     sa.Column('date', sa.DateTime(timezone=True)))
    date_idx = index_str(table, 'date', 'date')
    create_table(table, [date_idx])
    return table
示例#7
0
def make_query_queue_table():
    metadata = make_metadata(query_queue_engine)
    table =  sa.Table(settings.DB_APP_NAME + '_query_queue', metadata,
                      sa.Column('iden', sa.String, primary_key = True),
                      sa.Column('query', sa.Binary),
                      sa.Column('date', sa.DateTime(timezone = True)))
    date_idx = index_str(table, 'date', 'date')
    create_table(table, [date_idx])
    return table
示例#8
0
def make_query_queue_table():
    engine = g.dbm.engines['query_queue']
    metadata = make_metadata(engine)
    table =  sa.Table(g.db_app_name + '_query_queue', metadata,
                      sa.Column('iden', sa.String, primary_key = True),
                      sa.Column('query', sa.Binary),
                      sa.Column('date', sa.DateTime(timezone = True)))
    date_idx = index_str(table, 'date', 'date')
    create_table(table, [date_idx])
    return table
示例#9
0
 def sent_indices(tab):
     indices = [index_str(tab, 'to_addr', 'to_addr'),
                index_str(tab, 'date', 'date'),
                index_str(tab, 'ip', 'ip'),
                index_str(tab, 'kind', 'kind'),
                index_str(tab, 'fullname', 'fullname'),
                index_str(tab, 'account_id', 'account_id'),
                index_str(tab, 'msg_hash', 'msg_hash'),
                ]
示例#10
0
 def sent_indices(tab):
     indices = [index_str(tab, 'to_addr', 'to_addr'),
                index_str(tab, 'date', 'date'),
                index_str(tab, 'ip', 'ip'),
                index_str(tab, 'kind', 'kind'),
                index_str(tab, 'fullname', 'fullname'),
                index_str(tab, 'account_id', 'account_id'),
                index_str(tab, 'msg_hash', 'msg_hash'),
                ]
示例#11
0
 def sent_indices(tab):
     indices = [
         index_str(tab, "to_addr", "to_addr"),
         index_str(tab, "date", "date"),
         index_str(tab, "ip", "ip"),
         index_str(tab, "kind", "kind"),
         index_str(tab, "fullname", "fullname"),
         index_str(tab, "account_id", "account_id"),
         index_str(tab, "msg_hash", "msg_hash"),
     ]
示例#12
0
METADATA = make_metadata(ENGINE)

gold_table = sa.Table('reddit_gold', METADATA,
                      sa.Column('trans_id', sa.String, nullable = False,
                                primary_key = True),
                      # status can be: invalid, unclaimed, claimed
                      sa.Column('status', sa.String, nullable = False),
                      sa.Column('date', sa.DateTime(timezone=True),
                                        nullable=False),
                      sa.Column('payer_email', sa.String, nullable = False),
                      sa.Column('paying_id', sa.String, nullable = False),
                      sa.Column('pennies', sa.Integer, nullable = False),
                      sa.Column('secret', sa.String, nullable = True),
                      sa.Column('account_id', sa.String, nullable = True))

indices = [index_str(gold_table, 'status', 'status'),
           index_str(gold_table, 'date', 'date'),
           index_str(gold_table, 'account_id', 'account_id'),
           index_str(gold_table, 'secret', 'secret', unique = True),
           index_str(gold_table, 'payer_email', 'payer_email')]
create_table(gold_table, indices)

def create_unclaimed_gold (trans_id, payer_email, paying_id,
                           pennies, secret, date):
    gold_table.insert().execute(trans_id=trans_id,
                                status="unclaimed",
                                payer_email=payer_email,
                                paying_id=paying_id,
                                pennies=pennies,
                                secret=secret,
                                date=date)
示例#13
0
文件: gold.py 项目: z0r0/saidit
    sa.Column('status', sa.String, nullable=False),
    sa.Column('date',
              sa.DateTime(timezone=True),
              nullable=False,
              default=sa.func.now()),
    sa.Column('payer_email', sa.String, nullable=False),
    sa.Column('paying_id', sa.String, nullable=False),
    sa.Column('pennies', sa.Integer, nullable=False),
    sa.Column('secret', sa.String, nullable=True),
    sa.Column('account_id', sa.String, nullable=True),
    sa.Column('days', sa.Integer, nullable=True),
    sa.Column('subscr_id', sa.String, nullable=True),
    sa.Column('gilding_type', sa.String, nullable=True))

indices = [
    index_str(gold_table, 'status', 'status'),
    index_str(gold_table, 'date', 'date'),
    index_str(gold_table, 'account_id', 'account_id'),
    index_str(gold_table, 'secret', 'secret'),
    index_str(gold_table, 'payer_email', 'payer_email'),
    index_str(gold_table, 'subscr_id', 'subscr_id')
]
create_table(gold_table, indices)


class GoldRevenueGoalByDate(object):
    __metaclass__ = tdb_cassandra.ThingMeta

    _use_db = True
    _cf_name = "GoldRevenueGoalByDate"
    _read_consistency_level = tdb_cassandra.CL.ONE
示例#14
0
文件: gold.py 项目: 0xcd03/reddit
                      sa.Column('trans_id', sa.String, nullable = False,
                                primary_key = True),
                      # status can be: invalid, unclaimed, claimed
                      sa.Column('status', sa.String, nullable = False),
                      sa.Column('date', sa.DateTime(timezone=True),
                                nullable = False,
                                default = sa.func.now()),
                      sa.Column('payer_email', sa.String, nullable = False),
                      sa.Column('paying_id', sa.String, nullable = False),
                      sa.Column('pennies', sa.Integer, nullable = False),
                      sa.Column('secret', sa.String, nullable = True),
                      sa.Column('account_id', sa.String, nullable = True),
                      sa.Column('days', sa.Integer, nullable = True),
                      sa.Column('subscr_id', sa.String, nullable = True))

indices = [index_str(gold_table, 'status', 'status'),
           index_str(gold_table, 'date', 'date'),
           index_str(gold_table, 'account_id', 'account_id'),
           index_str(gold_table, 'secret', 'secret'),
           index_str(gold_table, 'payer_email', 'payer_email'),
           index_str(gold_table, 'subscr_id', 'subscr_id')]
create_table(gold_table, indices)


class GoldRevenueGoalByDate(object):
    __metaclass__ = tdb_cassandra.ThingMeta

    _use_db = True
    _cf_name = "GoldRevenueGoalByDate"
    _read_consistency_level = tdb_cassandra.CL.ONE
    _write_consistency_level = tdb_cassandra.CL.ALL
示例#15
0
文件: gold.py 项目: tolgaek/reddit
    METADATA,
    sa.Column("trans_id", sa.String, nullable=False, primary_key=True),
    # status can be: invalid, unclaimed, claimed
    sa.Column("status", sa.String, nullable=False),
    sa.Column("date", sa.DateTime(timezone=True), nullable=False, default=sa.func.now()),
    sa.Column("payer_email", sa.String, nullable=False),
    sa.Column("paying_id", sa.String, nullable=False),
    sa.Column("pennies", sa.Integer, nullable=False),
    sa.Column("secret", sa.String, nullable=True),
    sa.Column("account_id", sa.String, nullable=True),
    sa.Column("days", sa.Integer, nullable=True),
    sa.Column("subscr_id", sa.String, nullable=True),
)

indices = [
    index_str(gold_table, "status", "status"),
    index_str(gold_table, "date", "date"),
    index_str(gold_table, "account_id", "account_id"),
    index_str(gold_table, "secret", "secret", unique=True),
    index_str(gold_table, "payer_email", "payer_email"),
    index_str(gold_table, "subscr_id", "subscr_id"),
]
create_table(gold_table, indices)


def create_unclaimed_gold(trans_id, payer_email, paying_id, pennies, days, secret, date, subscr_id=None):

    try:
        gold_table.insert().execute(
            trans_id=str(trans_id),
            subscr_id=subscr_id,
示例#16
0
文件: gold.py 项目: wigg234/reddit
                      sa.Column('trans_id', sa.String, nullable = False,
                                primary_key = True),
                      # status can be: invalid, unclaimed, claimed
                      sa.Column('status', sa.String, nullable = False),
                      sa.Column('date', sa.DateTime(timezone=True),
                                nullable = False,
                                default = sa.func.now()),
                      sa.Column('payer_email', sa.String, nullable = False),
                      sa.Column('paying_id', sa.String, nullable = False),
                      sa.Column('pennies', sa.Integer, nullable = False),
                      sa.Column('secret', sa.String, nullable = True),
                      sa.Column('account_id', sa.String, nullable = True),
                      sa.Column('days', sa.Integer, nullable = True),
                      sa.Column('subscr_id', sa.String, nullable = True))

indices = [index_str(gold_table, 'status', 'status'),
           index_str(gold_table, 'date', 'date'),
           index_str(gold_table, 'account_id', 'account_id'),
           index_str(gold_table, 'secret', 'secret', unique = True),
           index_str(gold_table, 'payer_email', 'payer_email'),
           index_str(gold_table, 'subscr_id', 'subscr_id')]
create_table(gold_table, indices)


def with_sqlalchemy_session(f):
    """Ensures sqlalchemy session is closed (due to connection pooling)."""
    def close_session_after(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        finally:
            Session.remove()