示例#1
0
def MakeForkLabel(document,session):
	# databaseName = "dbpatterns"
	# connection = Connection()
	lm = LabelManager()
	rw = RWFM()
	# db = connection[databaseName]
	# rwlabel = db["rwlabel"]
	sublabel = session["rwlabel"]
	# r2  = session["rwlabel"]["readers"]
	# w = session["rwlabel"]["writers"]
	# just after creation of label
	rw.createObjLabel(sublabel,document["_id"])
	# temp2 = { "doc_id" : document["_id"],"owner" : session["rwlabel"]["owner"],"readers": r2,"writers": w }
	# rwlabel.save(temp2)
	# connection.disconnect()
	return {"bool":True}
示例#2
0
def MakeForkLabel(document, session):
    # databaseName = "dbpatterns"
    # connection = Connection()
    lm = LabelManager()
    rw = RWFM()
    # db = connection[databaseName]
    # rwlabel = db["rwlabel"]
    sublabel = session["rwlabel"]
    # r2  = session["rwlabel"]["readers"]
    # w = session["rwlabel"]["writers"]
    # just after creation of label
    rw.createObjLabel(sublabel, document["_id"])
    # temp2 = { "doc_id" : document["_id"],"owner" : session["rwlabel"]["owner"],"readers": r2,"writers": w }
    # rwlabel.save(temp2)
    # connection.disconnect()
    return {"bool": True}
示例#3
0
def MakeRWLabel(document, session):
    lm = LabelManager()
    rw = RWFM()
    print "MakeRWLabel"
    # databaseName = "dbpatterns"
    # connection = Connection()

    # db = connection[databaseName]
    # rwlabel = db["rwlabel"]
    sublabel = session["rwlabel"]
    r2 = session["rwlabel"]["readers"]
    w = session["rwlabel"]["writers"]
    # just after creation label
    temp2 = rw.createObjLabel(sublabel, document["_id"])
    # temp2 = { "doc_id" : document["_id"],"owner" : session["rwlabel"]["owner"],"readers": r2,"writers": w }
    print temp2
    if document["is_public"]:
        # readers = *
        readers = User.objects.all()
        r3 = []
        for x in readers:
            r3.append(x.id)
        # label is made to public
        temp3 = {
            "doc_id": document["_id"],
            "owner": session["rwlabel"]["owner"],
            "readers": r3,
            "writers": w
        }
        if rw.checkDowngrade(sublabel, temp2, temp3):
            # rwlabel.save(temp3)
            lm.updatelabel(document["_id"], temp3)
            # connection.disconnect()
            return {"bool": True, "type": "public"}
        else:
            # rwlabel.save(temp2)

            # connection.disconnect()
            return {"bool": False, "type": "public"}
    else:
        # if private make readers same as readers of subject.. then check for assignee.
        #readers  = owner
        #temp3 = {"doc_id" : document["_id"],"owner" : session["rwlabel"]["owner"],"readers": session["rwlabel"]["owner"],"writers": w}
        # rwlabel.save(temp2)
        # connection.disconnect()
        return {"bool": True, "type": "private"}
示例#4
0
def MakeRWLabel(document,session):
	lm = LabelManager()
	rw = RWFM()
	print  "MakeRWLabel"
	# databaseName = "dbpatterns"
	# connection = Connection()
	
	# db = connection[databaseName]
	# rwlabel = db["rwlabel"]
	sublabel = session["rwlabel"]
	r2  = session["rwlabel"]["readers"]
	w = session["rwlabel"]["writers"]
	# just after creation label
	print document['_id'].pk
	temp2  = rw.createObjLabel(sublabel,document["_id"].pk)
	# temp2 = { "doc_id" : document["_id"],"owner" : session["rwlabel"]["owner"],"readers": r2,"writers": w }
	print temp2
	if document["is_public"]:
		# readers = *
		readers = User.objects.all()
		r3 = []
		for x in readers:
			r3.append(x.id)
		# label is made to public

		temp3 = {"doc_id" : document["_id"].pk,"owner" : session["rwlabel"]["owner"],"readers": r3,"writers": w}
		if rw.checkDowngrade(sublabel,temp2,temp3):
			# rwlabel.save(temp3)
			lm.updateLabel(document["_id"].pk,temp3)
			# connection.disconnect()
			return {"bool": True, "type":"public"}
		else:
			# rwlabel.save(temp2)

			# connection.disconnect()
			return {"bool": False, "type":"public"}
	else:
		# if private make readers same as readers of subject.. then check for assignee.
		#readers  = owner
		#temp3 = {"doc_id" : document["_id"],"owner" : session["rwlabel"]["owner"],"readers": session["rwlabel"]["owner"],"writers": w}
		# rwlabel.save(temp2)
		# connection.disconnect()
		return {"bool":True,"type":"private"}