2012-10-19 18 views
0

我想將一個python列表發送給我的ladon服務。 考慮以下Python列表將python列表傳遞給使用泡沫的ladon

lst_col_title = [(1, 'Column1', 10, 'L'),(2, 'Column2', 15, 'L'),(3, 'Column3', 15, 'L'),(4, 'Column4', 10, 'L'),(5, 'Column5', 10, 'L')] 

是他們送這種名單的使用肥皂水拉冬服務任何可能的方式。

編輯 其實我想用肥皂水

str_report_name = 'OPENING BALANCE REPORT' 
    str_report_format = 'GENERAL' 
    lst_main_heading = [('<w><h><b><ds>NAME TRAVEL & TOURISM</ds></b></h></w>', 1), ('<p5><b>  <b></p5>', 2), ('<b><p2>P.O BOX 3000, JEDDAH 12345, KSA, Phone: 02 6845455</p2></b>', 3), ('<b><p2>Email: [email protected], Fax: 02 6873455, C.R.No: </p2></b>', 4), ('', 5)] 
    lst_header = [] 
    lst_report_header = [['', 'CREDIT NOTE', '', '<u><b><w>'], ['', '', '', ''], ['', 'No: RF/1', '', '<b>'], ['To, CASH KAAU (942)', '', 'Date: 01/01/2011', '<b>'], [' P.O. Box No. 3263,DOHA,QATAR', '', 'Code: C022  ', '<b>'], [' Tel: +91 9945 4561 45, Fax: +21 7894 7894', '', '', '<b>'], [' E-Mail: [email protected]', '', '', '<b>'], ['', '', '', ''], ['Please note that we have CREDITED your account with following details.', '', '', '']] 
    lst_page_header = [] 
    lst_footer = [] 
    lst_page_footer = [] 
    lst_report_footer = [['Two Thousand Two Hundred Seventeen Saudi Riyal Only ', '', '2217.00', '<b>'], ['', '', '', ''], ['Accountant', 'Created By:ADMIN', 'Manager', ''], ['', '', '', ''], ['Signature', '', '', '']] 
    lst_report_data = [('', '', '', '', ''), (1, '065-9778821549', 'ABOUNASEF/SEHAM KAMEL MRS', 'JED/CAI/JED', '2584.00'), ('', '', '<i>Less</i>: Cancellation Fee', '', '367.00'), ('', '', '', '', ''), ('', 'THIS IS TO CHECK THE NARRATION PRINTING THIS IS TO CHECK THE NARRATION PRINTING THIS IS TO CHECK THE NARR<i>', '', '', '')] 
    bln_show_column_heading = True 
    lst_col_title = [(1, 'Column1', 10, 'L'),(2, 'Column2', 15, 'L'),(3, 'Column3', 15, 'L'),(4, 'Column4', 10, 'L'),(5, 'Column5', 10, 'L')] 

以下Python變量發送到拉冬服務這是我拉冬服務

@ladonize(str,str,[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING], rtype=str) 
def generate_pdf_print(self, str_report_name,str_report_format,lst_main_heading, lst_header, lst_report_header, lst_page_header, lst_footer, lst_report_footer, lst_page_footer, lst_report_data, bln_show_column_heading, lst_col_title, **args): 

但[PORTABLE_STRING]不會做什麼我想要。

由於我是新的Web服務,我不知道如何處理複雜類型的pyase類型。

UPDATE

我已經創建了

lst_col_title = [(1, 'Column1', 10, 'L'),(2, 'Column2', 15, 'L'),(3, 'Column3', 15, 'L'),(4, 'Column4', 10, 'L'),(5, 'Column5', 10, 'L')] 

作爲新的拉冬類型:

class Table(LadonType): 
    slno = int 
    col_title = PORTABLE_STRING 
    col_size = int 
    col_align = PORTABLE_STRING 

和修改@ladonize如,

@ladonize(str,str,[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[ Table ], rtype=str) 

這是一個正確的方法嗎? 它提出了一個錯誤,我

' Server raised fault: ' 
classname: <class 'AccountEngine.Table'> 
Dictionary expected for prime_dict got "<type 'unicode'>" of value "1"' 

回答

0

我已經解決了這個問題,通過每個列表轉換爲字符串。

self.generate_pdf_file(str_report_name, 
       str_report_format, 
       str(lst_main_heading), 
       str(lst_header), 
       str(lst_report_header), 
       str(lst_page_header), 
       str(lst_footer), 
       str(lst_report_footer), 
       str(lst_page_footer), 
       str(lst_report_data), 
       bln_show_column_heading, 
       str(lst_col_title)) 

現在我@ladonize樣子:

@ladonize(str,str,str,str,str,str,str,str,str,str,str,str, rtype=str) 
def generate_pdf_print(self, str_report_name,str_report_format,lst_main_heading, lst_header, lst_report_header, lst_page_header, lst_footer, lst_report_footer, lst_page_footer, lst_report_data, bln_show_column_heading, lst_col_title, **args): 

並恢復那些valuesusing EVAL如下:

def generate_pdf_print(self,db, 
          str_report_name = 'OPENING BALANCE REPORT', 
          str_report_format = 'GENERAL', 
          lst_main_heading = [], 
          lst_header = [], 
          lst_report_header = [], 
          lst_page_header = [], 
          lst_footer = [], 
          lst_report_footer = [], 
          lst_page_footer = [], 
          lst_report_data = [], 
          bln_show_column_heading = True, 
          lst_col_title = [], 
          int_count_blocks_of_data_in_print = 1, 
          str_pdf_theme = 'Default' 
          ): 

    lst_main_heading = eval(lst_main_heading) 
    lst_header = eval(lst_header) 
    lst_report_header = eval(lst_report_header) 
    lst_page_header = eval(lst_page_header) 
    lst_footer = eval(lst_footer) 
    lst_page_footer = eval(lst_page_footer) 
    lst_report_footer = eval(lst_report_footer) 
    lst_report_data = eval(lst_report_data) 
    bln_show_column_heading = True 
    lst_col_title = eval(lst_col_title) 
1

我相信this是你在找什麼。基本上你想要做的是將每個元組轉換爲LadonType,然後返回這些類型的列表,類似於該教程中的listAlbumslistBands方法。 Here's LadonTypes的另一個教程。

拉冬

from ladon.ladonizer import ladonize 
from ladon.types.ladontype import LadonType 

class Calculator(object): 

    class Table(LadonType): 
     slno = int 
     colTitle = str 
     colSize = int 
     colAlign = str 


    @ladonize([Table],rtype=int) #notice the [], around table that means the input will be a list of Table LadonTypes. 
    def setTables(self,tables): 

     return len(tables) 

肥皂水

from suds.client import Client 

client = Client('http://localhost:8888/Calculator/soap/description') 

table = client.factory.create('Table') 

table.slno = 1 
table.colTitle = 'col1' 
table.colSize = 10 
table.colAlign = 'L' 

table2 = client.factory.create('Table') 
table2.slno = 2 
table2.colTitle = 'col2' 
table2.colSize = 15 
table2.colAlign = 'L' 

tableList = [table, table2] 

print client.service.setTables(tableList) 
+0

@ johnthexiii,謝謝你的幫助,我嘗試過使用LadonTypes,但是它顯示_Server引發錯誤:_。我編輯了我的問題。這顯示了我想要處理的複雜類型。 – SKT

+0

@SKT查看我的編輯。 – John

+0

@ johnthexiii感謝您的編輯。我已經解決了我的問題沒有LadonType。我不太瞭解通過LadonType,所以它對我很有幫助。 – SKT

0

It's posiible發送LadonType對象的列表。

例子:

class Mov(LadonType): 
    id = int 
    text = str 

@ladonize([Mov], rtype=PORTABLE_STRING) 
def ReceiveMovs(self, moves): 
    .... 

客戶端(ArrayOfXXX進行,其中xxx爲對象的類名):

moves = client.factory.create("ArrayOfMov") 

data1 = client.factory.create("Mov") 
data1.id = 1 
data1.text = "Test 1" 

data2 = client.factory.create("Mov") 
data2.id = 2 
data2.text = "Test 2" 

,並在客戶端中的最重要的部分:

moves["item"] = [data1, data2] 
res = client.service.ReceiveMovs(moves=moves) 

希望這個幫助!我的英語道歉。