You are not logged in linkOpaque.gif Log in linkOpaque.gif Join
You are here: Home » Members » senacle's Home » Appel de la fonction show

Une communauté active ?
Trouvez vous facilement les réponses à vos questions sur ZOPE, PLONE ou CPS (ou autres interfaces)
oui trés facilement
ca va
moyennement il faut pas mal chercher
non c'est assez dur
quasiment jamais

[ Results | Polls ]
Votes: 481
About
Created by
senacle
Document Post dans le forum
Last modified
25/01/06
State
published

Appel de la fonction show


Pour participer à cette discussion, cliquez ici pour vous inscrire.

Auteur Discussion
senacle
Appel de la fonction show
Affichage d'une image
Je souhaite afficher sur une page web un captcha.
Pour ce faire, j'utilise le code suivant, via une External Method :


import Image, ImageDraw, ImageFont, random

def randomString():
    ascii = 'abcdefghijkmnpqrstuvwxyz123456789'
    return ''.join(random.sample(ascii, 5))

def verify():
    image = Image.new('RGB', (115, 40), (39, 36, 81))
    font = ImageFont.truetype('arial.ttf', 25)
    draw = ImageDraw.Draw(image)
    draw.text((5, 5), randomString(), font = font, fill = (153, 204, 0))
    image.save('verify.jpg')
    image.show()


Les deux instructions
image.save('verify.jpg')
image.show()
provoquent un message d'erreur :

Error Type: AttributeError
Error Value: 'module' object has no attribute '_save'

Avez-vous une idée du pourquoi du comment ?
Posté le 25/01/2006 @ 08:50

encolpe
traceback !

Avec le traceback complet nous pourrions mieux compendre ce qui se passe.

Posté le 25/01/2006 @ 09:25

senacle
Traceback ?

Le traceback, c'est la page d'erreur ?

Posté le 25/01/2006 @ 09:35

encolpe
/error_log

Le traceback complet se trouve dans la ZMI à la racine du site dans l'objet error_log. Mettez des balises <pre> autour.

Posté le 25/01/2006 @ 09:53

senacle
Voilà

Site Error Log Site Error Log at  /error_log
Exception traceback

Time 2006/01/25 09:36:33.968 GMT+1 User Name (User Id) admin (admin) Request URL http://localhost:8080/Captcha/Test2 Exception Type AttributeError Exception Value module object has no attribute _save

Traceback (innermost last):

  • Module ZPublisher.Publish, line 113, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 40, in call_object Module Products.ExternalMethod.ExternalMethod, line 225, in __call__ __traceback_info__: ((), {}, None) Module X:\Zope-Instance\Extensions\Captcha.py, line 15, in verify Module Image, line 1349, in show Module Image, line 1913, in _showxv Module Image, line 434, in _dump Module Image, line 1305, in save * Module BmpImagePlugin, line 236, in _save

AttributeError: module object has no attribute _save

Display traceback as text

REQUEST form cookies tree-s eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuxEQ9AIOOB9Q lazy items SESSION > other TraversalRequestNameStack [] AUTHENTICATED_USER admin URL http://localhost:8080/Captcha/Test2 SERVER_URL http://localhost:8080 AUTHENTICATION_PATH '' PUBLISHED ACTUAL_URL http://localhost:8080/Captcha/Test2 URL0 http://localhost:8080/Captcha/Test2 URL1 http://localhost:8080/Captcha URL2 http://localhost:8080 BASE0 http://localhost:8080 BASE1 http://localhost:8080 BASE2 http://localhost:8080/Captcha BASE3 http://localhost:8080/Captcha/Test2 environ HTTP_COOKIE tree-s="eJzTyCkw5NLIKTDiClZ3hANXW3WuAmOuxEQ9AIOOB9Q" SERVER_SOFTWARE Zope/(Zope 2.8.1-final, python 2.3.5, win32) ZServer/1.1 SCRIPT_NAME '' REQUEST_METHOD GET PATH_INFO /Captcha/Test2 SERVER_PROTOCOL HTTP/1.1 channel.creation_time 1138177993 CONNECTION_TYPE keep-alive HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.7 HTTP_USER_AGENT Mozilla/5.0 (Windows; U; Windows NT 5.0; fr; rv:1.8) Gecko/20051111 Firefox/1.5 HTTP_REFERER http://localhost:8080/Captcha/Test2/manage_main SERVER_NAME SCASA REMOTE_ADDR 127.0.0.1 PATH_TRANSLATED \\Captcha\\Test2 SERVER_PORT 8080 HTTP_HOST localhost:8080 HTTP_ACCEPT text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 GATEWAY_INTERFACE CGI/1.1 HTTP_ACCEPT_LANGUAGE fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 HTTP_ACCEPT_ENCODING gzip,deflate HTTP_KEEP_ALIVE 300

Posté le 25/01/2006 @ 11:34

encolpe

Apparement vous sauvez unz image en mode brute Raw et ce format n'arriv pas à être sauvegardé Module BmpImagePlugin, line 236, in _save. Essayez de le convertir avant de le sauvegarder.

     Module ZPublisher.Publish, line 113, in publish
     Module ZPublisher.mapply, line 88, in mapply
     Module ZPublisher.Publish, line 40, in call_object
     Module Products.ExternalMethod.ExternalMethod, line 225, in __call__
      __traceback_info__: ((), {}, None)
     Module X:\Zope-Instance\Extensions\Captcha.py, line 15, in verify
     Module Image, line 1349, in show
     Module Image, line 1913, in _showxv
     Module Image, line 434, in _dump
     Module Image, line 1305, in save
    * Module BmpImagePlugin, line 236, in _save

Posté le 25/01/2006 @ 11:40

senacle
Comment ?

Il y a bien dans le code :

image.save(verify.jpg)
Mais le problème est presque le même.

Le traceback :

Traceback (innermost last):
  Module ZPublisher.Publish, line 113, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 40, in call_object
  Module Products.ExternalMethod.ExternalMethod, line 225, in __call__
   - __traceback_info__: ((), {}, None)
  Module X:\Zope-Instance\Extensions\Captcha.py, line 14, in verify
  Module Image, line 1305, in save
  Module JpegImagePlugin, line 409, in _save
AttributeError: module object has no attribute _save

Cette fois, c'est le module JpegImagePlugin qui pose problème. Est-ce la librairie PIL qui pose problème ?

Posté le 25/01/2006 @ 13:26

Recherche
Log in
Syndication
« November 2008 »
Su Mo Tu We Th Fr Sa
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30