Skip to content

Instantly share code, notes, and snippets.

@vangheem
Created April 29, 2016 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vangheem/a98de8dd5c3d00238bdba7509b142536 to your computer and use it in GitHub Desktop.
Save vangheem/a98de8dd5c3d00238bdba7509b142536 to your computer and use it in GitHub Desktop.
from plone.tiles import Tile
from plone.app.z3cform.widget import RelatedItemsFieldWidget
from plone.app.standardtiles.image import image_scales
from plone.autoform import directives as form
from plone.supermodel import model
from zope import schema
from zope.component import getMultiAdapter
from zope.component.hooks import getSite
from zope.globalrequest import getRequest
from zope.interface import Invalid
from zope.interface import invariant
class ImageTile(Tile):
def get_image(self):
# logic to get image from data
pass
class IImageTileSchema(model.Schema):
form.widget(image=RelatedItemsFieldWidget)
image = schema.List(
title=u"Image",
description=u"Reference image on the site.",
required=True,
default=[],
value_type=schema.Choice(
vocabulary='plone.app.vocabularies.Catalog'
)
)
@invariant
def validate_image(data):
pass
scale = schema.Choice(
title=u'Scale',
required=True,
source=image_scales,
default=u'large'
)
caption = schema.TextLine(
title=u'Caption',
required=False
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment