Ejemplo n.º 1
0
class Fetch(Base):
    """ A fetched account is a repote POP/IMAP account fetched into a local
    account.
    """
    __tablename__ = "fetch"

    id = db.Column(db.Integer(), primary_key=True)
    user_email = db.Column(db.String(255),
                           db.ForeignKey(User.email),
                           nullable=False)
    user = db.relationship(User,
                           backref=db.backref('fetches',
                                              cascade='all, delete-orphan'))
    protocol = db.Column(db.Enum('imap', 'pop3'), nullable=False)
    host = db.Column(db.String(255), nullable=False)
    port = db.Column(db.Integer(), nullable=False)
    tls = db.Column(db.Boolean(), nullable=False)
    username = db.Column(db.String(255), nullable=False)
    password = db.Column(db.String(255), nullable=False)
    last_check = db.Column(db.DateTime, nullable=True)
    error = db.Column(db.String(1023), nullable=True)
Ejemplo n.º 2
0
 def domain_name(cls):
     return db.Column(db.String(80),
                      db.ForeignKey(Domain.name),
                      nullable=False)
Ejemplo n.º 3
0
from mailu.admin import db, dkim
from mailu import app

from sqlalchemy.ext import declarative
from passlib import context
from datetime import datetime

import re
import time
import os
import glob

# Many-to-many association table for domain managers
managers = db.Table(
    'manager',
    db.Column('domain_name', db.String(80), db.ForeignKey('domain.name')),
    db.Column('user_email', db.String(255), db.ForeignKey('user.email')))


class CommaSeparatedList(db.TypeDecorator):
    """ Stores a list as a comma-separated string, compatible with Postfix.
    """

    impl = db.String

    def process_bind_param(self, value, dialect):
        if type(value) is not list:
            raise TypeError("Shoud be a list")
        for item in value:
            if "," in item:
                raise ValueError("No item should contain a comma")