Wezzul.com - It's the Dinglez

zope - Wezzul.com
In the project I am currently working on, I have to take data from a form field and generate images from it. These images need to have a transparent background. Here is the way I did that:


# create the original canvas giving it width and height
canvas = Image.new("RGBA", (W,H))

# select a font (you need to have compiled PIL with freetype installed for the
#_imagingft module to be on the server. This is necessary for this process.
font = ImageFont.truetype("/path/to/ttf/font", size_int)

# setup image to draw text on it
draw = ImageDraw.Draw(canvas)
black = "#000000"

# draw text on canvas, using offsets from upper left corner
draw.text((25,2),text,fill=black,font=font)

newImg = someFileHandle
canvas.save(newImg, "image_type")
newImg.close()


Done!
Posted on Thursday, February 01, 3:02pm in Tech by wezzul | Comments? | Permanent Link

This one took me a minute to figure out, but I'm happy I did. To create a new skin from the filesystem, and add your own layers to it (or in this case, add the layers from Plone Default), do the following:

#use this to get the skins directory
ps = getToolByName(self,'portal_skins')

# use this to add a new folder to that directory for your new skin
ps.manage_addFolder(skin_id, skin_id)

newSkinFolder = getattr(ps, skin_id)
path = newSkinFolder.absolute_url()

# get a set of tuples of all skins
paths = ps.getSkinPaths()

# these lines get the layers from Plone Default
defPath = paths[0]
defPath = defPath[1]

# add your new folder to the top of the Plone Default layers
defPath = skin_id "," defPath

# add the skin to the properties of portal_skins
ps.addSkinSelection(skin_id, defPath, 0, 0)


Pretty straight forward, right? In any case, it is helping me immensely with the current project.
Posted on Thursday, February 01, 8:59am in Tech by wezzul | Comments? | Permanent Link

Over the past year and some months, I have learned more than I ever wanted to know about Zope and Plone. The problem with those pieces of software is the lack of really good information for filesystem development there is out there. Hence the reason I am posting this here, so I can remember it.

To change the permissions on a filesystem file, in it's associated metadata file, add the following:

[security]
View=0:Authenticated,Manager


That will make it so that only Authenticated users and Managers can view the object. You can set this for any permissions that are available on the object. The 0 is the setting for acquisition. As expected, set this to 1 to turn acquisition on.

Current Music: RZA - The Birth
Posted on Tuesday, January 30, 4:15pm in Tech by wezzul | Comments (1) | Permanent Link