当前位置: 首页>>代码示例>>Python>>正文


Python Session.getUser方法代码示例

本文整理汇总了Python中session.Session.getUser方法的典型用法代码示例。如果您正苦于以下问题:Python Session.getUser方法的具体用法?Python Session.getUser怎么用?Python Session.getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在session.Session的用法示例。


在下文中一共展示了Session.getUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: printLoginBlock

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import getUser [as 别名]
    def printLoginBlock(self):
        content = ""

        currUser = Session.getUser()

        if currUser:
            uDescr = currUser.getDescription()

            content += (
                '<FORM name="login_form" METHOD=POST ACTION="../index.php" style="float:left; white-space:nowrap;">'
            )
            content += 'Welcome <span style="color:#FF0000">' + uDescr + "</span>"
            content += '<P><INPUT TYPE=SUBMIT NAME="logoutsubmit" VALUE="Logout" style="font-size:12px; elevation:above"></P></FORM>'

        else:
            content += '<FORM name="logout_form" METHOD=POST ACTION=' ">"

            content += """
					<P class="login">To view additional sections of the website, please log in:</P>

					Username:<BR/> 
					<INPUT type="text" value="" name="loginusername_field" size="13"><BR/>

					Password:<BR/> 
					<INPUT type="password" value="" name="loginpassword_field" size="13">

					<P>Automatic Login <INPUT type="checkbox" value="" name="persistentlogin_field"></P>

					<INPUT TYPE="submit" NAME="loginsubmit" VALUE="Login" style="font-size:12px; elevation:above">		
			</FORM>
			"""

        return content
开发者ID:mbikyaw,项目名称:OpenFreezer,代码行数:35,代码来源:general_output.py

示例2: printReagentInfo

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import getUser [as 别名]
	def printReagentInfo(self, cmd, reagent, errMsg=""):
		
		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()
		
		gOut = GeneralOutputClass()

		currUser = Session.getUser()
		currUserID = currUser.getUserID()
		
		sHandler = SystemSetHandler(db, cursor)
		pHandler = ProjectDatabaseHandler(db, cursor)
		
		# print menu
		content = gOut.printHeader() + gOut.printMainMenu()
		
		# common to all reagent types
		projectList = utils.unique(pHandler.findMemberProjects(currUserID, 'Writer') + pHandler.findMemberProjects(currUserID, 'Owner'))
		
		# Differentiate other properties by reagent type
		if reagent.getType() == 'Insert':
			
			# Fetch dropdown list values to output on the form
			iTypeList = sHandler.findAllSetValues("type of insert")
			statusList = sHandler.findAllSetValues("status")
			cloningMethodList = sHandler.findAllSetValues("insert cloning method")
			fpcsList = sHandler.findAllSetValues("5' cloning site")
			tpcsList = sHandler.findAllSetValues("3' cloning site")
			tagTypeList = sHandler.findAllSetValues("tag")
			tagPositionList = sHandler.findAllSetValues("tag position")
			openClosedList = sHandler.findAllSetValues("open/closed")
			speciesList = sHandler.findAllSetValues("species")
			verificationList = sHandler.findAllSetValues("verification")
		
			# Initialize property values
			iType = ""
			iName = ""
			iStatus = ""
			cloningMethod = ""
			projectID = ""
			fpcs = ""
			tpcs = ""
			tagType = ""
			tagPosition = ""
			openClosed = ""
			species = ""
			accession = ""
			altID = ""
			geneID = ""
			ensemblID = ""
			geneSymbol = ""
			fp_start = ""
			tp_stop = ""
			fwd_linker = ""
			rev_linker = ""
			funcDescr = ""
			verification = ""
			expComm = ""
			verComm = ""
			sequence = ""
		
			# Fetch POST values if available:
			allProps = reagent.getProperties()
			
			if allProps.has_key("type of insert"):
				iType = allProps["type of insert"]
			
			if allProps.has_key("name"):
				iName = allProps["name"]
				
			if allProps.has_key("status"):
				iStatus = allProps["status"]
			
			if allProps.has_key("insert cloning method"):
				cloningMethod = allProps["insert cloning method"]
			
			if allProps.has_key("packet id"):
				projectID = int(allProps["packet id"])
				
			if allProps.has_key("5' cloning site"):
				fpcs = allProps["5' cloning site"]
			
			if allProps.has_key("3' cloning site"):
				tpcs = allProps["3' cloning site"]
			
			if allProps.has_key("tag"):
				tagType = allProps["tag"]
			
			if allProps.has_key("tag position"):
				tagPosition = allProps["tag position"]
				
			if allProps.has_key("open/closed"):
				openClosed = allProps["open/closed"]
			
			if allProps.has_key("species"):
				species = allProps["species"]
				
#.........这里部分代码省略.........
开发者ID:mbikyaw,项目名称:OpenFreezer,代码行数:103,代码来源:reagent_output.py

示例3: printProjectInfo

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import getUser [as 别名]
	def printProjectInfo(self, cmd, project):
		
		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()
		
		uHandler = UserHandler(db, cursor)
		lHandler = LabHandler(db, cursor)

		gOut = GeneralOutputClass()

		currUser = Session.getUser()

		if cmd == 'view':

			projectID = project.getNumber()
			projectOwner = project.getOwner()
			ownerName = projectOwner.getFullName()
			ownerID = projectOwner.getUserID()
			projectName = project.getName()
			projectDescr = project.getDescription()
			
			# private or public
			isPrivate = project.isPrivate()
			
			if isPrivate:
				accessType = 'Private'
			else:
				accessType = 'Public'
			
			# Only allow modification by owner or admin AND disallow project deletion if there are reagents in it!!!
			modify_disabled = True
			delete_disabled = True
			
			if (currUser.getUserID() == ownerID) or (currUser.getCategory() == 'Admin'):
				modify_disabled = False

			if project.isEmpty():
				delete_disabled = False

			# Aug. 18/08: Changed b/c of new format
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			content += '''
				<FORM name="project_form" method="POST" action="%s">
			
					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="username_hidden" NAME="username"'''
					
			content += "value=\"" + currUser.getFullName() + "\">"
			
			content += '''
					<TABLE height="100%%">
						<TABLE width="770px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl">
							<TR>
								<TD class="detailedView_heading" style="white-space:nowrap;">
									PROJECT DETAILS PAGE
								</TD>
								
								<TD class="detailedView_heading" style="text-align:right">
									'''
			content += "<INPUT TYPE=\"submit\" name=\"modify_project\" value=\"Modify Project\""
			
			if modify_disabled:
				content += " disabled>"
			else:
				content += ">"
							
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_project\" value=\"Delete Project\" onClick=\"return confirmDeleteProject();\""
			
			if modify_disabled or delete_disabled:
				content += " disabled>"
			else:
				content += ">"
				
			content += '''
								</TD>
	
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project #
								</TD>
	
								<TD class="detailedView_value" width="87%%">
									%d
									<INPUT TYPE="hidden" name="packetID" value="%d">
								</TD>
	
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Owner:
								</TD>
	
#.........这里部分代码省略.........
开发者ID:mbikyaw,项目名称:OpenFreezer,代码行数:103,代码来源:project_output.py

示例4: printMainMenu

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import getUser [as 别名]

#.........这里部分代码省略.........
        tmp_ql.append("Search reagents")

        quickLinks["Reagent Tracker"] = tmp_ql

        tmp_ql = []

        tmp_ql.append("Add containers")
        tmp_ql.append("Search containers")

        quickLinks["Location Tracker"] = tmp_ql

        tmp_ql = []

        tmp_ql.append("Add projects")
        tmp_ql.append("Search projects")

        quickLinks["Project Management"] = tmp_ql

        tmp_ql = []

        tmp_ql.append("Change your password")
        tmp_ql.append("View your orders")

        quickLinks["User Management"] = tmp_ql

        content = """
			<div class="sidemenu" ID="mainMenu">
				<div class="menu-content">
					<ul class="menulist">
						<!-- menu goes here -->
						"""

        # Output the menu link IFF the user is authorized to access that page
        currUser = Session.getUser()

        if currUser:
            ucMapper = UserCategoryMapper(db, cursor)
            category_Name_ID_Map = ucMapper.mapCategoryNameToID()
            currUserCategory = category_Name_ID_Map[currUser.getCategory()]

            # print "Content-type:text/html"
            # print
            allowedSections = uHandler.getAllowedSections(currUserCategory)
            # print `allowedSections`

            for name in currentSectionNames:

                if name in allowedSections:

                    # added Jan. 7/09
                    if name in menuTypes:
                        # print "Content-type:text/html"
                        # print
                        # print name

                        content += '<DIV style="border-top:3px double #FFF8DC; border-right:6px double #FFF8DC; border-bottom:3px double #FFF8DC; border-left:6px double #FFF8DC; margin-top:2px; width:162px; padding-top:5px; padding-bottom:0;">'

                        content += "<DIV style=\"background-image:url('../pictures/small_bg.png'); width:166px; height:30px;\">"

                        content += '<select style="cursor:pointer; width:150px; background:#FFF8DC; font-weight:bold; color:#555; font-size:9pt; margin-top:3px; margin-left:2px;  font-family:Helvetica; border:0;" onChange="openPage(this.options[this.options.selectedIndex]);">'

                        content += (
                            '<option selected style="cursor:pointer; font-weight:bold; color:#555; font-size:9pt; border:0; font-family:Helvetica;" value="">&nbsp;'
                            + name
                            + "</option>"
                        )
开发者ID:mbikyaw,项目名称:OpenFreezer,代码行数:70,代码来源:general_output.py

示例5: printSubmenuHeader

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import getUser [as 别名]

#.........这里部分代码省略.........

            project_submenu_names.append("Add projects")
            project_submenu_links["Add projects"] = "../Project.php?View=1"

            project_submenu_names.append("Search projects")
            project_submenu_links["Search projects"] = "../Project.php?View=2"

            current_selection_names = project_submenu_names
            current_selection_links = project_submenu_links

        elif submenu_type == "User":

            user_submenu_names = []
            user_submenu_links = {}

            user_submenu_names.append("Add users")
            user_submenu_links["Add users"] = "../User.php?View=1"

            user_submenu_names.append("Search users")
            user_submenu_links["Search users"] = "../User.php?View=2"

            user_submenu_names.append("Change your password")
            user_submenu_links["Change your password"] = "../User.php?View=6"

            user_submenu_names.append("Personal page")
            user_submenu_links["Personal page"] = "User.php?View=7"

            user_submenu_names.append("View your orders")
            user_submenu_links["View your orders"] = "../User.php?View=8"

            current_selection_names = user_submenu_names
            current_selection_links = user_submenu_links

        elif submenu_type == "Lab":

            lab_submenu_names = []
            lab_submenu_links = {}

            lab_submenu_names.append("Add laboratories")
            lab_submenu_links["Add laboratories"] = "../User.php?View=3"

            lab_submenu_names.append("Search laboratories")
            lab_submenu_links["Search laboratories"] = "../User.php?View=4"

            current_selection_names = lab_submenu_names
            current_selection_links = lab_submenu_links

            # There can be permission differentiations within a menu section as well (e.g. Projects - only Creators can create, buit Writers can view)
        currUser = Session.getUser()

        ucMapper = UserCategoryMapper(db, cursor)
        category_Name_ID_Map = ucMapper.mapCategoryNameToID()

        currUserCategory = category_Name_ID_Map[currUser.getCategory()]
        allowedSections = uHandler.getAllowedSections(currUserCategory)

        # print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        # print					# DITTO
        # print `allowedSections`

        content = ""

        for name in current_selection_names:

            if name in allowedSections:

                if name == "Personal page":
                    content += '<LI class="submenu">'

                    content += '<IMG SRC="../pictures/star_bullet.gif" WIDTH="10" HEIGHT="10" BORDER="0" ALT="plus" class="menu-leaf">'

                    content += (
                        '<span class="linkShow" style="font-size:9pt" onClick="redirectToCurrentUserDetailedView('
                        + ` currUser.getUserID() `
                        + ');">'
                        + name
                        + "</span>"
                    )

                    content += "</LI>"

                    content += '<form name="curr_user_form" style="display:none" method="post" action="user_request_handler.py">'

                    content += (
                        '<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username" VALUE="'
                        + currUser.getFullName()
                        + '">'
                    )

                    content += '<INPUT type="hidden" id="curr_user_hidden" name="view_user">'
                    content += "</FORM>"
                else:
                    content += '<LI class="submenu">'

                    content += '<IMG SRC="../pictures/star_bullet.gif" WIDTH="10" HEIGHT="10" BORDER="0" ALT="plus" class="menu-leaf">'

                    content += '<a class="submenu" href="' + current_selection_links[name] + '">' + name + "</a>"
                    content += "</LI>"

        return content
开发者ID:mbikyaw,项目名称:OpenFreezer,代码行数:104,代码来源:general_output.py

示例6: printLabInfo

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import getUser [as 别名]
	def printLabInfo(self, cmd, newLab, errCode=""):
		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()
		
		uHandler = UserHandler(db, cursor)
		lHandler = LabHandler(db, cursor)
		
		currUser = Session.getUser()
		
		gOut = GeneralOutputClass()

		if cmd == 'view':

			labID = newLab.getID()
			labHead = newLab.getLabHead()
			labName = newLab.getName()
			labCode = newLab.getLabCode()
			labDescr = newLab.getDescription()
			address = newLab.getAddress()
			accessLevel = newLab.getDefaultAccessLevel()
			
			# Determine if 'Delete' button should be disabled - if there are members in the lab, disallow deletion
			labMembers = lHandler.findMembers(labID)

			delete_disabled = True

			if len(labMembers) == 0:
				delete_disabled = False
			
			# Only allow modification by admin
			modify_disabled = True
			
			# July 3/07: Can further disallow modification of labs other than the one currUser belongs to; however, this might be too restrictive.  Keep it in the back of our minds but out of the website for now.
			#if (currUser.getCategory() == 'Admin') and (currUser.getLab().getID() == labID):
			if (currUser.getCategory() == 'Admin'):
				modify_disabled = False
			
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			content += '''
				<FORM name="lab_form" method="POST" action="%s">
			
					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"'''
					
			content += "value=\"" + currUser.getFullName() + "\">"
			
			content += '''
					<TABLE width="775px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl">
						<TR>
							<TD colspan="6" class="detailedView_heading" style="padding-left:250px">
								LABORATORY DETAILS PAGE
								'''
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:50px;\" name=\"modify_lab\" value=\"Change Lab Info\""
			
			if modify_disabled:
				content += " disabled>"
			else:
				content += ">"
							
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_lab\" value=\"Delete Lab\" onClick=\"return verifyDeleteLab()\""
			
			if modify_disabled or delete_disabled:
				content += " disabled>"
			else:
				content += ">"
				
			content += '''
							</TD>

						</TR>
					
						<TR>
							<TD class="projectDetailedViewName">
								Name:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labName" value="%s">

								<!-- lab ID a hidden value -->
								<INPUT TYPE="hidden" name="labID" value="%d">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName">
								Lab head:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labHead" value="%s">
							</TD>
						</TR>
#.........这里部分代码省略.........
开发者ID:mbikyaw,项目名称:OpenFreezer,代码行数:103,代码来源:user_output.py

示例7: printUserInfo

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import getUser [as 别名]
	def printUserInfo(self, cmd, user, errCode=""):
		
		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()
		
		uHandler = UserHandler(db, cursor)
		lHandler = LabHandler(db, cursor)
		pHandler = ProjectDatabaseHandler(db, cursor)
		
		ucMapper = UserCategoryMapper(db, cursor)
		category_ID_Name_Map = ucMapper.mapCategoryIDToName()
		category_Name_ID_Map = ucMapper.mapCategoryNameToID()

		currUser = Session.getUser()
		
		gOut = GeneralOutputClass()
					
		if cmd =='create':
			
			username = user.getUsername()
			firstname = user.getFirstName()
			lastname = user.getLastName()
			email = user.getEmail()
			passwd = user.getPassword()
			
			lab = user.getLab()
			uLabID = lab.getID()
			uLabName = lab.getName()
			
			labs = lHandler.findAllLabs()

			# changed Aug. 18/08 - new format
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			content += '''
				<FORM NAME="create_user_form" METHOD="POST" ACTION="%s" onSubmit="return verifyAddUser();">

					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"'''
					
			content += "value=\"" + currUser.getFullName() + "\">"
			
			content += '''
					<TABLE width="760px" cellpadding="5" cellspacing="5">

						<TH colspan="4" style="color:#0000FF; border-top:1px groove black; border-bottom: 1px groove black; padding-top: 10px; padding-top:5px;">
							ADD NEW USER
							<P style="color:#FF0000; font-weight:normal; font-size:8pt; margin-top:5px;">Fields in red marked with an asterisk (<span style="font-size:9pt; color:#FF0000;">*</span>) are mandatory</P>
						</TH>

						<TR>
							<TD style="width:150px; vertical-align:top; padding-top:10px; color:#FF0000;">
								Laboratory:&nbsp;<sup style="font-size:10pt; color:#FF0000;">*</sup>
							</TD>

							<TD style="vertical-align:top; padding-top:10px">
								<SELECT id="labList" name="labs">
									<OPTION>Select Lab</OPTION>
								'''
			# sort labs by name
			labSortedDict = {}		# will store (labName, labID) tuples 
			labNames = []			# just hold lab names
			
			for labID in labs.keys():
				labName = labs[labID]
				labNames.append(labName)
				labSortedDict[labName] = labID
				
			labNames.sort()

			#for labID in labs.keys():
			for labName in labNames:
				labID = labSortedDict[labName]
				labName = labs[labID]
				content += "<OPTION ID=\"" + `labID` + "\" NAME=\"lab_optn\" VALUE=\"" + `labID` + "\""
				
				if labID == uLabID:
					content += " SELECTED>" + labName
				else:
					content += ">" + labName
					
				content += "</OPTION>"
					
			content += '''
								</SELECT>
								<BR/>
								<P id="lab_warning" style="color:#FF0000; display:none">Please select a laboratory name from the dropdown list above.</P>
							</TD>
						</TR>

						<TR>
							<TD class="createViewColName" style="color:#FF0000;">
								Username:&nbsp;<sup style="font-size:10pt; color:#FF0000;">*</sup>
							</TD>

							<TD class="createViewColValue">
#.........这里部分代码省略.........
开发者ID:mbikyaw,项目名称:OpenFreezer,代码行数:103,代码来源:user_output.py


注:本文中的session.Session.getUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。