Exemple #1
0
	def test_get(self):
		obj = dict(type="user", name="testuser", email="testmail", fullname="Test User")
		objstore.post(**obj)
		obj1 = objstore.get(type="user", name="testuser")
		# clear nulls
		del obj1['_updated']
		for key in obj1.keys():
			if not obj1[key]: 
				del obj1[key]
		self.assertEquals(obj, obj1)
Exemple #2
0
    def load(self):
        """resume session via cookie or start a new guest session"""

        if "sid" in self.req.cookies:
            self.__dict__.update(objstore.get(type="session", name=self.req.cookies["sid"]))
        if not self.user:
            self.user = "******"
            self.new_sid()
            database.get()
            database.conn.begin()
            objstore.post(type="session", user=self.user, name=self.name)
            database.conn.commit()
Exemple #3
0
def get(**args):
    """start a new session"""
    req = http_request.req

    req.session = Session(req)
    if req.form.get("user"):
        database.get()
        database.conn.begin()
        req.session.new()
        database.conn.commit()
    else:
        req.session.load()

    return {
        "user": req.session.user,
        "sid": req.session.name,
        "userobj": objstore.get(type="user", name=req.session.user),
    }
Exemple #4
0
	def test_vector(self):
		obj = dict(type="user", name="testuser", email="testmail", fullname="Test User")
		objstore.post(type="user", name="testuser", userrole=['Admin', 'Manager'])
		obj1 = objstore.get(type="user", name="testuser")
		self.assertTrue('Admin' in obj1['userrole'])
		self.assertTrue('Manager' in obj1['userrole'])