Esempio n. 1
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        model = Secret('asdf')
        DBSession.add(model)
Esempio n. 2
0
    def create_secret(self, *args, **kwargs):
        '''create secret, encrypt, and return tuple'''
        self._secret = Secret()
        for key in ('expiry_time', 'snippet_type', 'lifetime_reads', 'early_delete'):
            if key == 'early_delete':
                self._secret.flag_delete_early = kwargs['early_delete']
                continue

            if key == 'lifetime_reads':
                if kwargs['lifetime_reads'] < 0:
                    self._secret.flag_unlimited_reads = True
                    continue

            setattr(self._secret, key, kwargs[key])

        session = DBSession()
        secret, uuid = self._encrypt(kwargs['plaintext'])
        DBSession.add(secret)
        DBSession.flush()
        return (secret, uuid)