當前位置: 首頁>>代碼示例>>Python>>正文


Python DBSession.flush方法代碼示例

本文整理匯總了Python中tribal.model.DBSession.flush方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.flush方法的具體用法?Python DBSession.flush怎麽用?Python DBSession.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tribal.model.DBSession的用法示例。


在下文中一共展示了DBSession.flush方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: upload

# 需要導入模塊: from tribal.model import DBSession [as 別名]
# 或者: from tribal.model.DBSession import flush [as 別名]
    def upload( self, **kw ):
        try:
            print "*-" * 30
            print type( kw["attachment"] )
            print "*-" * 30

            file_path = kw["attachment"].filename
            ( pre, ext ) = os.path.splitext( file_path )

            path_prefix = os.path.join( config.download_dir, "sys" )
            if not os.path.exists( path_prefix ) : os.makedirs( path_prefix )

            file_name = "%s%.4d%s" % ( dt.now().strftime( "%Y%m%d%H%M%S" ), random.randint( 1, 1000 ), ext )

            print file_name
            print "*-" * 30

            full_path = os.path.join( path_prefix, file_name )

            f = open( full_path, "wb" )
            f.write( kw["attachment"].file.read() )
            f.close()

            db_file_name = kw.get( "attachment_name", None ) or file_name
            if db_file_name.find( "." ) < 0 : db_file_name = db_file_name + ext

            obj = UploadObject( file_name = db_file_name, file_path = os.path.join( "sys", file_name ) )
            DBSession.add( obj )
            DBSession.flush()
            return obj.id
        except:
            traceback.print_exc()
            return None
開發者ID:LamCiuLoeng,項目名稱:internal,代碼行數:35,代碼來源:root.py

示例2: add_attachments

# 需要導入模塊: from tribal.model import DBSession [as 別名]
# 或者: from tribal.model.DBSession import flush [as 別名]
 def add_attachments(self, attachments=[], key='attachment'):
     ids = []
     for att in attachments:
         upObj = UploadObject(**{'_file_path':att, 'file_name': att.split('\\')[-1].split('/')[-1]})
         DBSession.add(upObj)
         DBSession.flush()
         ids.append(upObj.id)
     setattr(self, key, '|'.join(map(str, ids)))
開發者ID:LamCiuLoeng,項目名稱:internal,代碼行數:10,代碼來源:sysutil.py

示例3: copyAttachments

# 需要導入模塊: from tribal.model import DBSession [as 別名]
# 或者: from tribal.model.DBSession import flush [as 別名]
 def copyAttachments( cls, ids ):
     if isinstance( ids, str ) or isinstance( ids, unicode ):
         ids = [ids]
     objs = [DBSession.query( UploadObject ).get( int( id ) ) for id in ids if id]
     attachments = []
     for obj in objs:
         if obj:
             attachment = UploadObject( **{'file_name': obj.file_name, 'file_path': obj._file_path} )
             DBSession.add( attachment )
             DBSession.flush()
             attachments.append( attachment.id )
     return attachments
開發者ID:LamCiuLoeng,項目名稱:internal,代碼行數:14,代碼來源:prepress.py

示例4: merge

# 需要導入模塊: from tribal.model import DBSession [as 別名]
# 或者: from tribal.model.DBSession import flush [as 別名]
 def merge(cls, **kw):
     try:
         sod = cls.get_sod(kw['so_no'], kw['line_no'])
         if not sod:
             soh = MglobalErpSO.get_so(kw['so_no']) if not kw.has_key('local_so_id') else MglobalErpSO.get(kw['local_so_id'])
             if not soh:
                 soh = MglobalErpSO(**{'so_no':kw['so_no'], 'cust_po_no':kw['cust_po_no'], 'customer_code':kw['customer_code'], 'customer_name':kw['customer_name']})
                 DBSession.add(soh)
                 DBSession.flush()
             sod = cls(**{'local_so_id':soh.id, 'so_no':kw['so_no'], 'line_no':kw['line_no'], 'item_code':kw['item_code'], 'order_qty':kw['order_qty'], 'create_date':kw['create_date']})
             item = MglobalMasterItem.get_by_erp_code(sod.item_code)
             if item:
                 sod.local_item_id = item.id
             DBSession.add(sod)
         else:
             sod.order_qty = kw['order_qty']
             item = MglobalMasterItem.get_by_erp_code(sod.item_code)
             if item:
                 sod.local_item_id = item.id
         return sod
     except Exception, e:
         log.exception(str(e))
         raise
開發者ID:LamCiuLoeng,項目名稱:internal,代碼行數:25,代碼來源:mglobalpack.py


注:本文中的tribal.model.DBSession.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。