DeprecationWarning: ใน ReportLab

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

ผมทดลองใช้งาน ReportLab มาพักหนึ่ง
พบ DeprecationWarning: ระหว่างสั่งให้สร้าง PDF ไฟล์

/usr/lib/python2.5/site-packages/reportlab/pdfbase/ttfonts.py:407: DeprecationWarning: struct integer overflow masking is deprecated
  stm.write(pack(">LLL", checksum, offset, len(data)))
/usr/lib/python2.5/site-packages/reportlab/pdfbase/ttfonts.py:419: DeprecationWarning: struct integer overflow masking is deprecated
  stm.write(pack('>L', checksum))

แต่ก็สร้างไฟล์ PDF ออกมาให้ได้นะครับ
จำเป็นต้องเข้าไปแก้ไขอย่างไรหรือไม่ครับ
เพราะขณะที่ทดลองใช้งาน reportlab.platypus
ในส่วนของการใช้งาน Table

...
cursor.execute("select code,name from staff order by code")
result = cursor.fetchall()
t=Table(result,2*[0.4*inch], 10*[0.4*inch])
t.setStyle([
	('FONT',(0,0),(-1,-1),'Norasi',10,12),
	('GRID',(0,0),(-1,-1),1,(0.1,0.1,0.1),
	)])
Story.append(t)
doc.build(Story, onFirstPage=myFirstPage,onLaterPages=myLaterPages)
...

งาน PDF ที่ออกมานั้น GRID ไม่ครอบคลุมข้อมูลทั้งหมดครับ
ประมาณว่าข้อมูลมันล้นตารางออกมา ไม่รู้ว่าจะเกี่ยวกับ warning ข้างต้นหรือเปล่า

sugree's picture

ไม่เกี่ยวครับมันแค่เตือนว่า integer overflow masking จะกลายเป็น error ใน Python 2.6 ช่วงนี้ใช้ไปก่อน กว่าจะถึงตอนนั้น ReportLab คงแก้แล้ว

ขอบคุณครับ ได้รับคำอธิบายแล้วสบายใจขึ้นครับ
ว่าที่ใช้งาน Table ไม่ได้นั้น ไม่ได้มาจาก Warning ดังกล่าว

จึงตั้งใจหาสาเหตุจากส่วนอื่นต่อ
ตอนนี้ใช้งานได้ดีแล้ว
ใช้งาน grid ได้อย่างถูกต้องแล้วครับ

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น