Example #1
0
def enableUser():
    email = sys.argv[1]
    ploud_config.initializeConfig()
    dsn = PLOUD.dsn
    models.initialize_sql(dsn)
    config = Configurator()
    config.manager.push({'registry': config.registry, 'request': None})

    conn = ploud_config.PLOUD_POOL.getconn()
    cursor = conn.cursor()

    cursor.execute("SELECT email FROM waitinglist "
                   "WHERE completed = %s and email=%s",(False,email))

    row = cursor.fetchone()
    if row is None:
        print "Can't find email: %s"%email
        return

    transaction.begin()
    password = ''.join(
        [random.choice(ALLOWED_SITE_NAME_CHARS) for i in range(8)])
    user = models.User(email, password)
    user.type = 0
    token = user.token
    ptah.get_session().add(user)
    print email, token
    signup.send_activation(email, token)

    cursor.execute("UPDATE waitinglist SET completed = %s WHERE email=%s",
                   (True, email))
    cursor.close()
    conn.commit()
    transaction.commit()
Example #2
0
def setUp(test):
    config.loadPackage('ploud.frontend')

    testing.setUpConfig(test)
    testing.setUpTestAsModule(test, 'ploud.TESTS')
    ploud.TESTS = sys.modules['ploud.TESTS']

    initialize_sql('sqlite://')

    smtplib.SMTP = SMTP

    global configFile
    hnd, configFile = tempfile.mkstemp()
    f = open(configFile, 'wb')
    f.write("""[frontend]\nregistration=true""")
    f.close()
    ploud_config.initializeConfig(configFile, True)

    pyramid_config = Configurator()
    pyramid_config.begin()