예제 #1
0
def register(webin):
    Logr.log("test",
             "TEST CONSTANT " + str(getattr(constants, "testvar", None)))
    pcn = json.loads(webin.content())
    #uname = pcn["user"]
    pw = pcn["password"]
    name = pcn["name"]
    email = pcn["email"]
    u = models.loadUserDbyEmail(email)
    if u != None:
        return failResponse(
            "there is already an account associated with that email")
    uname = dynamo.genNewUserId()
    nu = models.UserD(None)
    nu.topic = '/user/' + uname
    nu.name = name
    nu.storage_allocation = constants.initial_storage_allocation
    nu.bandwidth_allocation = constants.initial_bandwidth_allocation
    nu.setPassword(pw)
    nu.email = email
    vcode = models.genId("register")
    nu.validation_code = vcode
    nu.validated = 0
    rs = ses.sendValidationEmail(nu)
    if rs:
        nu.dynsave(True)
        dynamo.bumpCount("/user/count")
        return okResponse()
    else:
        return failResponse("Unable to send email to " + email)
예제 #2
0
def updateUser(webin):
    Logr.log("test",
             "TEST CONSTANT " + str(getattr(constants, "testvar", None)))
    pcn = json.loads(webin.content())
    uname = pcn["userId"]
    vprint("uname", uname)
    cks = webin.checkSessionResponse()
    if cks: return cks
    session = webin.session
    suserId = misc.pathLast(session.user)
    if suserId != uname:
        return failResponse("wrongUser")
    pw = pcn.get("password", None)
    name = pcn["name"]
    email = pcn["email"].strip()
    u = models.loadUserD("/user/" + uname, webin.pageStore)

    if u == None:
        return failResponse()
    oldemail = getattr(u, "email", "")
    if email and (oldemail != email):
        eu = dynamo.emailToUser(pcn["email"])
        if eu != None:
            return failResponse("emailInUse")
    nu = models.UserD(None)
    nu.topic = '/user/' + uname
    nu.name = name
    if pw: nu.setPassword(pw)
    nu.email = email
    vprint("old email", oldemail, "new ", email)
    if (oldemail != email):
        rs = ses.sendEmailChangedEmail(nu)
        if rs:
            nu.dynsave(False)
            if oldemail:
                dynamo.deleteEmailToUserEntry(oldemail)
            return okResponse()
        else:
            return failResponse("Unable to send email to " + email)
    nu.dynsave(False)
    return okResponse()
예제 #3
0
jb.save()



models.addImageToDb("cg","sthellens")

models.loadImageD("/image/cg/sthellens")

dyn.getDict("Album","/album/ccc/bathing_1/8")
ims = models.allImages()


uu = dyn.getUser('/user/cg')
uuu = models.loadUserD('/user/foobmm')

nn = models.UserD(None)
nn.topic = '/user/foob'
nn.name  = "mr foob"
nn.setPassword("abcdef")
nn.email = "*****@*****.**"
nn.dynsave()



models.deleteSnap("/album/cg/The_Ambassadors/3/1")

models
ss = models.loadSnapD("/album/cg/The_Ambassadors/3/1")

ss = snaps.getSnap("/album/cg/The_Ambassadors/3/1")
dyn.setCount("/album/cg/The_Dutch_Proverbs/count",1)
예제 #4
0
def setTumblrToken(webin):

    cn = webin.content()
    #print "CONTENT",cn
    cob = json.loads(cn)
    token = cob["oauth_token"]
    token_secret = cob["oauth_token_secret"]
    verifier = cob["verifier"]
    signingIn = cob.get("signingIn", False)
    if not signingIn:
        cks = webin.checkSessionResponse()
        if cks: return cks
    access_token = oauth_tumblr.getAccessToken(verifier, token, token_secret)
    #print "ACCESS TOKEN ",access_token
    atkj = json.dumps(access_token)
    if signingIn:
        uinfj = oauth_tumblr.getUserInfo(access_token["oauth_token"],
                                         access_token["oauth_token_secret"])
        #print "UINFJ",uinfj
        uinf = json.loads(uinfj)
        tuname = uinf["response"]['user']['name']
        vprint("TUNAME", tuname)
        exu = models.loadUserDbyTumblr(tuname)
        rs = {"tumblr_name": tuname}
        if exu:
            vprint("Existing tumblr user")
            exu.tumblr_token = atkj
            exu.dynsave(False)
            tac = getattr(exu, "accepted_terms", 0)
            #tac = 1
            rs["accepted_terms"] = tac
            utp = exu.topic
            uid = misc.pathLast(utp)
            rs["userId"] = uid
            if tac:
                # go ahead and generate a new session for this fellow
                s = exu.newSession()
                stp = s.topic
                sid = misc.pathLast(stp)
                rs["sessionId"] = sid
            return okResponse(rs)
        else:
            vprint("NEW TUMBLR USER")
            ucnt = dynamo.getCount("/user/count")
            if ucnt >= constants.maxUsers:
                rs["hit_limit"] = 1
                return okResponse(rs)
            uid = dynamo.genNewUserId()
            nu = models.UserD(None)
            nu.topic = '/user/' + uid
            nu.name = tuname
            nu.tumblr_name = tuname
            nu.storage_allocation = constants.initial_storage_allocation
            nu.bandwidth_allocation = constants.initial_bandwidth_allocation
            nu.accepted_terms = 0
            nu.tumblr_token = atkj
            nu.dynsave(True)
            dynamo.bumpCount("/user/count")
            vprint("NEW TUMBLR USER SAVED")
            rs["accepted_terms"] = 0
            rs["userId"] = uid

            return okResponse(rs)
    """ getting a access token in the course of a post to tumblr """
    sess = webin.session
    user = sess.user
    userD = models.loadUserD(user)
    atkj = json.dumps(access_token)
    userD.tumblr_token = atkj
    userD.dynsave(False)
    return okResponse()
예제 #5
0
snaps = store.snaps
import store.jobs
jobs = store.jobs
import api.job
ajob = api.job
import model.utilization

import ops.logs
logs = ops.logs
import store.log
logstore = store.log

jt = "/job/test22/554"
jb = models.getJob(jt)

uu = models.UserD("/user/test22")
uu.utilization()

im =  image.loadImageD("/image/test22/sistine77")


"""

sz = im.size()
rct = image.Rect(image.Point(0,0),im.size())
ofl = "/mnt/ebs1/imagediver/images/test22/sistine25/tiling/r.jpg"
ofl= "tiling/r.jpg"
im.cropImage(rct,ofl,targetWidth=sz.x)


ifl = "/mnt/ebs1/imagediver/images/test22/sistine25/stepdown/s_0.jpg"
예제 #6
0
"""
PYTHONPATH=$PYTHONPATH:"/mnt/ebs0/imagediverdev/py"
export PYTHONPATH
cd /mnt/ebs0/imagediverdev/py
python admin_scripts/more_users.py vh duane "Astoria Vintage Hardware"

"""

import constants

constants.dbDir = "/mnt/ebs0/imagediverdev/dbs/"
constants.logDir = "/mnt/ebs0/imagediverdev/log/"

import model.models
models = model.models
import sys
args = sys.argv
user = args[1]
passwd = args[2]
name = args[3]


u = models.UserD("/user/"+user)
u.name=name
print str(u.__dict__)

u.save()

u.setPassword(passwd)

예제 #7
0
#!/usr/bin/env python
"""
PYTHONPATH=$PYTHONPATH:"/mnt/ebs0/imagediver/py"
export PYTHONPATH
cd /mnt/ebs0/imagediver/py
python admin_scripts/new_store.py
python admin_scripts/add_users.py
python image_scripts/add_images.py

"""

import model.models
models = model.models

u = models.UserD("/user/cg")
u.name = "Chris Goad"
u.save()

u.setPassword("psanlecu")

u = models.UserD("/user/cumtux")
u.name = "Clatsop County Historical Society"
u.save()

u.setPassword("cumtux")
"""


ds.insert(
    {"name":"Clatsop County Historical Society",
     },'/user/cumtux','/type/userD');