On Feb 8, 1:30 am, "schnuer.com" <[EMAIL PROTECTED]> wrote:
> Hi,
> Thanks for the tips and i've been trying different approaches all day and
> reading lots of docs with varying success. Now i can get my file and all but
> i still cant get it into the database. Here follows the code and the trace,
> the code is not pretty yet but i just wanted it to work since i need to get
> finished with this, this has held me up since Sunday.
>
> Thank you for your help,
> Fabian

Hi, I do have this working, but without upload progress. Here is some
relevant code:

def update_pictures(self, img1=None, img2=None, img3=None, img4=None,
**kw):
    "Updates the users images."
    user = identity.current.user
    msg = ""
    if img1 != None:
        if img1.filename.strip():
            user.img1, user.img1_thumb = self.resize_images(img1)
[...]

def resize_images(self, img):
    """Return resized image and a thumbnail."""
    main = 250
    thumb = 90
    thumbImg = None
    mainImg = None
    print "###resize_images, img, filename of img", img, img.filename
    if img != None and img.filename.strip():
        import Image
        im = Image.open(img.file)
        thumbImg = im.resize((thumb, thumb), Image.NEAREST)
        mainImg = im.resize((main, main), Image.NEAREST)
        return (b64encode(mainImg.tostring("jpeg", "RGB")),
                b64encode(thumbImg.tostring("jpeg", "RGB")))
    return None, None


# Here, you are supposed to browse to server/image/[username]/1/2 for
a thumbnail
# of a second image for given user..

@expose(content_type="image/jpeg")
def image(self, user_name, thumb=None, num="1"):
    u = User.selectBy(user_name=user_name)[0]
    if u:
        if thumb == "0": thumb = None
        if thumb:
            if num == "1":
#                    return u.img1_thumb
                return b64decode(u.img1_thumb)
            elif num == "2":
#                    return u.img2_thumb
                return b64decode(u.img2_thumb)

Hope this helps, let me know if you have questions.. I'm using sqlite
right now.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to