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


Python Directory类代码示例

本文整理汇总了Python中Directory的典型用法代码示例。如果您正苦于以下问题:Python Directory类的具体用法?Python Directory怎么用?Python Directory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: send_content

  def send_content(self, request):
    '''Main loop for this view'''
    # get the meetings this user is in
    if request.session.user.superuser == '1':
      #the superuser gets sent straight to the Administrator page
      #pm_meetings = Directory.get_meetings()
      #meetings = []
      self.forward_to_superuser(request)

    
    else:
      pm_meetings = []
      meetings = []
      for meeting in Directory.get_meetings():               
        if Directory.get_group(meeting.id, request.session.user.id) != None:
          if self.user_is_pm(meeting, request.session.user.id):
            pm_meetings.append(meeting)
          else:
            meetings.append(meeting)
    
      # send to the appropriate page
      if len(meetings)+len(pm_meetings) == 0: #and request.session.user.superuser != '1': #superuser is now redirected before this line
        self.no_meetings(request)
      
      elif len(meetings)+len(pm_meetings) == 1: #and request.session.user.superuser != '1': #superuser is now redirected before this line
        if len(meetings) == 1:
          self.forward_to_meeting(request, meetings[0])
        else:
          #self.forward_to_meeting(request, pm_meetings[0])
	  self.forward_to_pm(request, pm_meetings[0])
      
      else:
        self.show_meetings(request, meetings, pm_meetings)
开发者ID:ssaltzman,项目名称:POET,代码行数:33,代码来源:MeetingChooser.py

示例2: editFiles

 def editFiles(self, dirName, pattern):
     if not self.isReady:
         print "FileEditor is not ready"
         return
     dir = Directory(dirName)
     filenames = dir.filenames(pattern)
     for filename in filenames:
         self.editFileBlocks(filename)
开发者ID:pombredanne,项目名称:simpatico,代码行数:8,代码来源:FileEditor.py

示例3: save_user

 def save_user(self, request):
   '''Saves (or creates) a user'''
   userid = request.getvalue('userid', 'New')
   if (userid == 'New'):
     user = Directory.create_user(request.session.user.id)
   else:
     user = Directory.get_user(userid)
   for key in Directory.USER_FIELDS:
     setattr(user, key, request.getvalue(key, ''))
   user.save()
开发者ID:ssaltzman,项目名称:POET,代码行数:10,代码来源:Administrator.py

示例4: meetings_page

  def meetings_page(self, request):
    '''Shows the meetings (embedded in the main page table)'''
    request.writeln('<div class="module"><h1>Programs</h1>')
    
    # current meetings
    request.writeln('''
      <div align="center" name="meetingselect" id="meetingselect">
	<div id="meetinglist">
    ''')
    
    meetings = Directory.get_meetings()
    meetings.sort(lambda a,b: cmp(a.name, b.name))
    for meeting in meetings:
      request.writeln('''<div class="progBox">
			<span style="display:none;" id="meetinginfo_''' + meeting.id + '''">''' + str(meeting.id) + '''/''' + meeting.view + '''/''' + meeting.name + '''</span>
			<span style="float:left;">'''+meeting.name+'''</span>
			<span style="float:right;">
			  <a class="ui-icon ui-icon-pencil" href='javascript:editMeeting("''' + meeting.id + '''");'></a>
			  <a class="ui-icon ui-icon-closethick" href='javascript:deleteMeeting("''' + meeting.id + '''");'></a>
			  <a class="ui-icon ui-icon-plusthick" href='javascript:renameMeeting("''' + meeting.id + '''");'></a>
			</span>
		      </div>
    ''')
    request.writeln('''</div><br/>
	  <center>
	    <div id="programFormDialog" style="display:none;" title="Create New Program">
	    ''' + request.cgi_form(_adminaction='newmeeting', meetingname=None, meetingview=None, meetingusers=None, name='npForm') + '''
	      <select style="display:none;" name="meetingview"><option value="poet">POET Acquisition Collaboration</option></select>
	      <table border=0 style="height:100%;padding:10px;">
		<tr>
		  <td>Name:</td><td><input type="text" name="meetingname" size="20" /></td>
		</tr>
		<tr>
		  <td>Users:</td><td><select name="meetingusers" multiple size="5">
    ''')
    users = Directory.get_users()
    users.sort(lambda a,b: cmp(a.username, b.username))
    for user in users:
	request.writeln('''<option id="'''+ user.id + '''">''' + user.name + '''</option>''')
    request.writeln('''
		  </select></td>
		</tr>
		<tr>
		  <td><input type="submit" id="newProgram" value="Create" onclick="document.npForm.submit();" /></td><td><input type="button" id="cancelNP" value="Cancel" /></td>
		</tr>
	      </table>
	      </form>
	    </div>
	    <input type="button" id="createNP" value="Create New Program"></input>	  
	  </center>
	</div>
      </div>
    ''')
开发者ID:ssaltzman,项目名称:POET,代码行数:53,代码来源:Administrator.py

示例5: do_generate_users

 def do_generate_users(self, request):
   '''Automatically generates users'''
   try:
     name = request.getvalue('name', '')
     assert name != ''
     start = int(request.getvalue('start', 'error'))
     end = int(request.getvalue('end', 'error'))
     passlen = int(request.getvalue('passlength', 'error'))
   except:
     request.writeln('<p align="center"><font color="red">Error: Some fields were not entered correctly or were blank; autogeneration cancelled.</font></p>')
     return
   rand = random.Random()
   index_len = len(str(end))
   for i in range(start, end + 1):
     user = Directory.create_user(request.session.user.id)
     newname = name
     for j in range(len(str(i)), index_len):  # pad lower numbers with zeros
       newname += '0'
     newname += str(i)
     user.name = newname
     user.email = ''
     user.username = newname
     user.password = ''
     if passlen > 0:
       for i in range(passlen - 1):  # all letters except last char is a number
         user.password += rand.choice(ASCII_CHARS)
       user.password += rand.choice(DIGIT_CHARS)
     user.save()
开发者ID:ssaltzman,项目名称:POET,代码行数:28,代码来源:Administrator.py

示例6: users_page

 def users_page(self, request):
   '''Shows the users (embedded in the main page table)'''
   # the title
   request.writeln('<center><div class="i">Users:</div></center>')
   
   # current users
   request.writeln('''
     <p align="center">
     <select name="userselect" id="userselect" size="15">
   ''')
   users = Directory.get_users()
   users.sort(lambda a,b: cmp(a.username, b.username))
   for user in users:
     if user.superuser == '1':
       request.writeln('<option value="">' + html(user.name) + '</option>')
     else:
       request.writeln('<option value="' + user.id + '">' + html(user.name) + '</option>')
   request.writeln('''
     </select>
     </p>
     <p align="center">
       <a href="javascript:editUser();">Edit</a>
       |
       <a href="javascript:deleteUser();">Delete</a>
     </p>
     <hr>
     <p align="center">
       <a href="''' + request.cgi_href(_adminaction='edituser') + '''">Add New User</a>
       |
       <a href="''' + request.cgi_href(_adminaction='generateusers') + '''">Autogenerate Users</a>
       |
       <a href="''' + request.cgi_href(_adminaction='exportusers') + '''">Export User Information</a>
     </p>
   ''')
开发者ID:ssaltzman,项目名称:POET,代码行数:34,代码来源:Administrator.py

示例7: send_game

  def send_game(self, request):
    '''Shows the game window'''
    # get the game objects
    game = datagate.get_item(request.getvalue('global_rootid'))
    teams = game.search1(name='groups')
    team = Directory.get_group(game.id, request.session.user.id)
    if not team:
      raise 'You have not been added to a team in this game.'
    try: 
      chats = game.search1(name='chats') # just use first team's chat for now -- eventually we want to see what team the user is on and link to the chat parent for that team
    except IndexError:
      raise 'You cannot play a StrikeCom game without any teams.  Please add at least one team and try again.'
    chat = chats.search1(name=team.name)
    board = game.search1(name='board')
    turns = game.search1(name='turns')

    request.writeln(HTML_HEAD)
    request.writeln('''
      <frameset border="0" cols="*,200">  
        <frameset border="0" rows="*,50">
          <frame marginheight="0" marginwidth="0" name="playingboard" src="''' + request.cgi_href(global_rootid=turns.id, view='StrikeComPlayingBoard', frame=None) + '''">
          <frame scrolling="no" marginheight="0" marginwidth="0" name="legend" src="''' + request.cgi_href(view='StrikeComLegend', frame=None) + '''">
        </frameset>
        <frame scrolling="no" marginheight="0" marginwidth="0" name="chat" src="''' + request.cgi_href(global_rootid=chat.id, view='StrikeComCommenter', frame=None) + '''">
      </frameset>
    ''')    
开发者ID:ssaltzman,项目名称:POET,代码行数:26,代码来源:StrikeCom.py

示例8: send_main_frames

 def send_main_frames(self, request):
   # get the game objects
   game = datagate.get_item(request.getvalue('global_rootid'))
   teams = game.search1(name='groups')
   team = Directory.get_group(game.id, request.session.user.id)
   if not team:
     raise 'You have not been added to a team in this game.'
   try: 
     chats = game.search1(name='chats') # just use first team's chat for now -- eventually we want to see what team the user is on and link to the chat parent for that team
   except IndexError:
     raise 'You cannot play a StrikeCom game without any teams.  Please add at least one team and try again.'
   chat = chats.search1(name=team.name)
   board = game.search1(name='board')
   turns = game.search1(name='turns')
   
   # send the html
   request.writeln(HTML_HEAD_NO_CLOSE)
   request.writeln('''
     </head>
     <frameset border="0" rows="45,*">
       <frame marginheight="0" marginwidth="0" scrolling="no" name="navigation" src="''' + request.cgi_href(subview='navigation') + '''">
       <frame marginheight="0" marginwidth="0" scrolling="no" name="game" src="''' + request.cgi_href(subview='game') + '''">
     </frameset>
     </html>
   ''')
开发者ID:ssaltzman,项目名称:POET,代码行数:25,代码来源:StrikeCom.py

示例9: send_comment

 def send_comment(self, userid, prefix, comment):
   self.lock.acquire()  # only send one comment at a time (since we're hitting multiple rootids)
   try:
     sent_to = {}
     for sessionid, rootid in self.sessions.items():
       # get the session; if the session has expired, remove and move on
       session = Directory.get_session(sessionid)
       if not session:
         del self.sessions[sessionid]
         continue
         
       # if we've already sent to this rootid, skip and move on
       if sent_to.has_key(rootid):
         continue
       sent_to[rootid] = rootid
       
       # find the actual parent of this comment
       root = datagate.get_item(rootid)
       if not root:
         print "RatingProxy couldn't find rootid:", rootid
         continue
       parentid = self.find_parent(root, prefix) or rootid
       
       # create and send the event to the system (goes to all interested users)
       # I'm using a blank windowid so it goes to anyone looking at this rootid
       item = datagate.create_item(parentid=parentid, creatorid=userid)
       item.text = comment
       item.save()
       event = BaseView.views['rating']._create_event(item, 'processAdd')
       Events.send_event(rootid, event)
   
   finally:
     self.lock.release()
开发者ID:ssaltzman,项目名称:POET,代码行数:33,代码来源:RatingProxy.py

示例10: do_delete_users

 def do_delete_users(self, request):
   '''Delete ranges of autogenerated users'''
   prefix = request.getvalue('prefix', '')
   if len(prefix) == 0:
     return
   for user in Directory.get_users():
     if len(user.name) >= len(prefix) and user.name[:len(prefix)] == prefix:
       user.delete()
开发者ID:ssaltzman,项目名称:POET,代码行数:8,代码来源:Administrator.py

示例11: edit_user

 def edit_user(self, request):
   '''Shows the edit user screen'''
   user = Directory.get_user(request.getvalue('userid', 'New'))
   if user == None:
     user = datagate.Item()  # just create a dummy item
     userid = 'New'
   else:
     userid = user.id
开发者ID:ssaltzman,项目名称:POET,代码行数:8,代码来源:Administrator.py

示例12: answer_question_action

  def answer_question_action(self, request, id, ans, com):
    creator = request.session.user
    item = datagate.get_item(id)
    answers = item.search1(name="answers")
    #if this user has already answered this question, update it instead of creating it
    answer = None
    for each in answers:
      if each.who == creator.name:
        answer = each
    if not answer:
      answer = datagate.create_item(creatorid=creator.id, parentid=answers.id)
    
    answer.name = 'answer'
    answer.who = creator.name
    answer.when = time.strftime('%a, %d %b %Y %H:%M:%S')
    answer.answer = ans
    answer.comment = com
    answer.save()
    
    meeting = Directory.get_meeting(request.getvalue('global_rootid', ''))
    parent = meeting.get_parent()
    activities = parent.search1(view='questioneditor')
    userAnswer = activities.search1(name="userAnswers")
    userFound = False
    if userAnswer != None:
      for user in userAnswer:
        if user.name == creator.name:
          userFound = True
          answered = None
          for child in user:
            if child.questionId == id:
              answered = child
          if not answered:
            answered = datagate.create_item(creatorid=creator.id, parentid=user.id)
          answered.questionId = id
          answered.answer = ans
          answered.when = time.strftime('%a, %d %b %Y %H:%M:%S')
          answered.save()
    if userFound == False or userAnswer == None:
      userCreated = datagate.create_item(creatorid=creator.id, parentid=userAnswer.id)
      userCreated.name = creator.name
      answered = datagate.create_item(creatorid=creator.id, parentid=userCreated.id)
      answered.questionId = id
      answered.answer = ans
      answered.when = time.strftime('%a, %d %b %Y %H:%M:%S')
      answered.save()

    if id not in creator.answeredQuestions:
      creator.answeredQuestions.append(id)

    #creator.backtrack = 0 #resets the user to their first unanswered question
    if creator.backtrack < 0:
      creator.backtrack += 1 #moves the user forward one question
    creator.save()

    event = QuestionAsker.next_question(self,request,creator)
    return event
开发者ID:ssaltzman,项目名称:POET,代码行数:57,代码来源:QuestionAsker.py

示例13: exportCSV_action

  def exportCSV_action(self, request, filters):
    meeting = Directory.get_meeting(request.getvalue('global_rootid', ''))
    
    events = []

    #dictionaries = answerData, answerDataAveraged, questionPOETData, questionSetData, poetData, setData 
    dictionaries = ReportFindings.makeDictionaries(self, meeting, filters, True)

    exportEvents = ReportFindings.makeExports(self, dictionaries) 
    events.extend(exportEvents)

    return events
开发者ID:ssaltzman,项目名称:POET,代码行数:12,代码来源:ReportFindings.py

示例14: set_picked

 def set_picked(self,request):
   creator = request.session.user
   meeting = Directory.get_meeting(request.getvalue('global_rootid', ''))
   parent = meeting.get_parent()
   meetingRoot = parent.get_parent()
   groups = meetingRoot.search1(name='groups')
   allGroups = groups.get_child_items(self)
   for group in allGroups:
     allChildren = group.get_child_items(self)
     for child in allChildren:
       if creator.id == child.user_id:
         return group.sets
   return []
开发者ID:ssaltzman,项目名称:POET,代码行数:13,代码来源:QuestionAsker.py

示例15: get_initial_events

  def get_initial_events(self, request, rootid):
    '''Retrieves a list of initial javascript calls that should be sent to the client
       when the view first loads.  Typically, this is a series of add_processor
       events.'''
    global potentialQuestionList
    creator = request.session.user
    meeting = Directory.get_meeting(request.getvalue('global_rootid', ''))
    parent = meeting.get_parent()
    meetingRoot = parent.get_parent()
    groups = meetingRoot.search1(name='groups')
    activities = parent.search1(view='questioneditor')
    userGroup = ''
        
    #find which user group user belongs to
    allGroups = groups.get_child_items(self)
    for group in allGroups:
      allChildren = group.get_child_items(self)
      for child in allChildren:
        if creator.id == child.user_id:
          userGroup = group.name
          #setPicked = group.sets 
          
    setPicked = QuestionAsker.set_picked(self,request)

    #get the question ids of the questions that have already been answered
    groupMapping = activities.search1(name="groupMapping")

    potentialQuestionList = ''
    for group in groupMapping:
      if group.name == userGroup:
        for child in group.get_child_items(self):
          if child.name == 'quesId':
            potentialQuestionList = child.quesId[:]

    filterParams = QuestionAsker.filter_params(self,request,setPicked)
    events = []

    try:
      if (creator.backtrack * -1) < len(creator.answeredQuestions):
        events.append(Event('enableBack'))
      else:
        events.append(Event('disableBack'))
    except AttributeError:
      creator.backtrack = 0
                    
    if not filterParams[0] == "":
      events.append(Event('populateEnd', filterParams[0],str(creator.id)))
    else:
      events.append(Event('populateForm', filterParams[1], filterParams[2], filterParams[3], filterParams[4], str(creator.id), filterParams[5]))
    return events
开发者ID:ssaltzman,项目名称:POET,代码行数:50,代码来源:QuestionAsker.py


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