Blog
Empowering your data with open source
- Filter Posts
Archetypes, AnnotationStorage and image scaling
The ImageField Archetypes schema field type has a methode for scaling the images. But when using AnnotationStorage() this doesn't work out of the box. After defining the sizes for the field:
atapi.ImageField(
'image',
storage=atapi.AnnotationStorage(),
widget=atapi.ImageWidget(
label=_(u"Product Family Image"),
description=_(u"add an image to the product family"),
),
validators=('isNonEmptyFile'),
sizes = {'large' : (768, 768),
'preview' : (400, 400),
'mini' : (200, 200),
'thumb' : (128, 128),
},
),
You need to override __bobo_traverse__ to access the scaled image.
# workaround to make resized images
def __bobo_traverse__(self, REQUEST, name):
"""Transparent access to image scales
"""
if name.startswith('image'):
field = self.getField('image')
image = None
if name == 'image':
image = field.getScale(self)
else:
scalename = name[len('image_'):]
if scalename in field.getAvailableSizes(self):
image = field.getScale(self, scale=scalename)
if image is not None and not isinstance(image, basestring):
# image might be None or '' for empty images
return image
return base.ATCTContent.__bobo_traverse__(self, REQUEST, name)
Now you can access the different sizes of the image by simple urls like "/image_mini"
See also: Products.ATContentTypes.ATNewsItem
Thanks to: http://www.unc.edu/~jj/plone/
seantis Questionnaire released
Der seantis Questionnaire ist released als open source.
Seantis Questionnaire ist eine django Applikation zur Erstellung von online Questionnaires und Befragungen. seantis Questionnaire lässt sich einfach an Benutzerwünsche anpassen und eignet sich auch für fortgeschrittene Abhängigkeiten innerhalb des Fragebogens.
Es wurde als Teil einer medizinischen Studie mit jährlichen Follow-Up-Fragebögen designt und enthält daher features zum automatischen Versand von e-mail-Einladungen.
Features
- Multiple Questionnaires, multiple pages (QuestionSets) per questionnaire, multiple runs of same questionnaire per subject (eg. for annual surveys)
- Multilingual using the django transmeta application.
- Questions (ie. 6) & SubQuestions (ie. 6a), with appropriate layout tweaks.
- Email Invitations (direct URL to Questionnaire)
- Does not require Django’s authentication system to answer questionnaires
- CSV export of answers.
- Complex dependencies utilising a full Boolean Expression Parser, and Javascript support. eg. (6a=yes and 6b=yes) OR 5=no
- Easily extensible question types (Question Processor + Template, and Answer Processor)
- Built-in Question types include Open (single line), Open (text area), Yes/No, Yes/No/Dont Know, Yes/No/Comment, Single Choice, Single Choice + Freeform Option, Multiple Choice, Multiple Choice + Freeform Option(s), Number Range, Time Period.
- Django Signals on completion of QuestionSets and Questionnaires