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


Python Session.delete方法代码示例

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


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

示例1: confirmPersonCandidate

# 需要导入模块: from np.model import Session [as 别名]
# 或者: from np.model.Session import delete [as 别名]
def confirmPersonCandidate(ticket):
    'Move changes from the PersonCandidate table into the Person table'
    # Query
    candidate = Session.query(model.PersonCandidate).filter(model.PersonCandidate.ticket==ticket).filter(model.PersonCandidate.when_expired>=datetime.datetime.utcnow()).first()
    # If the ticket exists,
    if candidate:
        # If the person exists,
        if candidate.person_id:
            # Update person
            person = Session.query(model.Person).get(candidate.person_id)
            person.username = candidate.username
            person.password_hash = candidate.password_hash
            person.nickname = candidate.nickname
            person.email = candidate.email
            person.email_sms = candidate.email_sms
            # Reset rejection_count
            person.rejection_count = 0
        # If the person does not exist,
        else:
            # Add person
            Session.add(model.Person(candidate.username, candidate.password_hash, candidate.nickname, candidate.email, candidate.email_sms))
        # Delete ticket
        Session.delete(candidate)
        # Commit
        Session.commit()
    # Return
    return candidate
开发者ID:AlphaStaxLLC,项目名称:networkplanner,代码行数:29,代码来源:people.py

示例2: delete

# 需要导入模块: from np.model import Session [as 别名]
# 或者: from np.model.Session import delete [as 别名]
 def delete(self, id):
     'DELETE /scenarios/id: Delete an existing item'
     # Initialize
     personID = h.getPersonID()
     # Load
     scenario = Session.query(model.Scenario).filter(model.Scenario.id==id).first()
     # If the scenario doesn't exist,
     if not scenario:
         return dict(isOk=0, message='Scenario %s does not exist' % id)
     # If the user is not the owner,
     if personID != scenario.owner_id:
         return dict(isOk=0, message='You are not the owner of scenario %s' % id)
     # Delete
     Session.delete(scenario)
     Session.commit()
     # Return
     return dict(isOk=1)
开发者ID:fparaggio,项目名称:networkplanner,代码行数:19,代码来源:scenarios.py

示例3: dict

# 需要导入模块: from np.model import Session [as 别名]
# 或者: from np.model.Session import delete [as 别名]
        scenario.input = scenarioInput
        Session.add(scenario)
        Session.commit()
        # Unzip
        scenarioFolder = scenario.getFolder()
        store.unzipData(scenarioFolder, scenarioData)
        # Run
        try:
            scenario.run()
            scenario.status = model.statusDone
        except:
            scenario.output = dict(traceback=''.join(traceback.format_exception(*sys.exc_info())))
            scenario.status = model.statusFailed
        finally:
            Session.commit()
        # Pack result into outgoing message
        outgoingPack = scenarioID, scenario.output, open(scenarioFolder + '.zip', 'rb').read() if os.path.exists(scenarioFolder + '.zip') else None, scenario.status
        # Send outgoing message
        outgoingMessage = amqp.Message(pickle.dumps(outgoingPack))
        outgoingMessage.properties['delivery_mode'] = 2
        channel.basic_publish(outgoingMessage, exchange=outgoingExchange, routing_key=outgoingKey)
        # Clean up
        shutil.rmtree(scenarioFolder)
        store.removeSafely(scenarioFolder + '.zip')
        Session.delete(scenario)
        Session.commit()
    # Close channel
    channel.close()
    # Close connection
    connection.close()
开发者ID:AlphaStaxLLC,项目名称:networkplanner,代码行数:32,代码来源:processor.py


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