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


Python Session.delete方法代码示例

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


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

示例1: delete_obj

# 需要导入模块: from inphosite.model.meta import Session [as 别名]
# 或者: from inphosite.model.meta.Session import delete [as 别名]
def delete_obj(obj):
    """
    Deletes any arbitrary object from the SQLAlchemy Session and cascades deletes to evaluations.

    :param obj: object to delete

    """
    Session.delete(obj)
    Session.flush()
开发者ID:etboggs,项目名称:inphosite,代码行数:11,代码来源:helpers.py

示例2: getentries

# 需要导入模块: from inphosite.model.meta import Session [as 别名]
# 或者: from inphosite.model.meta.Session import delete [as 别名]
def getentries(db_dir):
    #to do feb 10: do something more elegant than just delete existing and rewrite...perhaps only write new?
    
    #first, clear out the current table
    #Session.query(SEPEntry).delete()
    #Session.flush()
    #Session.commit()
    
    entries = defaultdict(lambda: {'title' : '', 'published' : False, 'status' : ''})
    
    pars = HTMLParser.HTMLParser()
    
    #get published entries
    published = open('/Users/inpho/SitesOld/dev/entries-published.txt')
    status = open(os.path.join(db_dir , 'entrystatus.txt'))
        
    entrylist = open(os.path.join(db_dir, 'entries.txt'))

    #set up entries dict
    for line in entrylist:
        line = line.split('::')
        sep_dir = pars.unescape(re.sub('<(/)?[a-zA-Z]*>', '', line[0]))
        title = re.sub("\\\\\'", "'", pars.unescape(re.sub('<(/)?[a-zA-Z]*>', '', line[1])))
        entries[sep_dir]['title'] = title
        
    for line in published:
        line = re.sub('\\n', '', line)
        if entries[line]['title']:
            entries[line]['published'] = True
        else:
            print "uh-oh, " + line + "doesn't appear to be in dict object"
    
    for line in status:
        line = line.split('::')
        if entries[line[0]]['title']:
            entries[line[0]]['status'] = line[1]
            #print "status = " + line[1] + ' for ' + line[0]
        else:
            print "uh-oh, " + line[0] + "doesn't appear to be in dict object"
        
    
    for key in entries.keys():
        #so, what I should really do here is figure out whether the entry already has a place in the table; if so, update its existing stats; if not, 
        #insert a new one; 
        #also need to check if old entries in sepentries table are no longer in file...
        
        entry_q = Session.query(SEPEntry)
        o = SEPEntry.title.like(entries[key]['title'])
        entry_q = entry_q.filter(o)
        # if only 1 result, go ahead and view that idea
        if entry_q.count() == 0:
            entry_add = SEPEntry(entries[key]['title'], key, entries[key]['published'], entries[key]['status'])
            Session.add(entry_add)
        elif entry_q.count() == 1:
            #replace data from most recent from SEPMirror
            entry = entry_q.first()
            entry.title = entries[key]['title']
            entry.published = entries[key]['published']
            entry.status = entries[key]['status']
    #need to really add something here to delete entries no longer in the DB...
    
    entry_q2 = Session.query(SEPEntry)
    for entry in entry_q2:
        if not entries[entry.sep_dir]['title']:
            print str(entry.title) + " appears to have been deleted from SEPMirror; deleting from InPhO database."
            Session.delete(entry)    
    
    Session.flush()
    Session.commit()
开发者ID:camerontt2000,项目名称:inphosite,代码行数:71,代码来源:sepparse.py


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