/
leadimage.py
55 lines (42 loc) · 1.32 KB
/
leadimage.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
from plone.app.contenttypes import _
from plone.autoform.interfaces import IFormFieldProvider
from plone.dexterity.interfaces import IDexterityContent
from plone.namedfile import field as namedfile
from plone.supermodel import model
from zope import schema
from zope.component import adapter
from zope.interface import implementer
from zope.interface import provider
from zope.interface import Interface
class ILeadImageMarker(Interface):
pass
@provider(IFormFieldProvider)
class ILeadImage(model.Schema):
image = namedfile.NamedBlobImage(
title=_(u'label_leadimage', default=u'Lead Image'),
description=u'',
required=False,
)
image_caption = schema.TextLine(
title=_(u'label_leadimage_caption', default=u'Lead Image Caption'),
description=u'',
required=False,
)
@implementer(ILeadImage)
@adapter(IDexterityContent)
class LeadImage(object):
def __init__(self, context):
self.context = context
@property
def image(self):
return self.context.image
@image.setter
def image(self, value):
self.context.image = value
@property
def image_caption(self):
return self.context.image_caption
@image_caption.setter
def image_caption(self, value):
self.context.image_caption = value