[silva.core.interfaces][Sylvain Viollon] Extend and refactor som...
[email protected] Wed, 06 Nov 2013 17:23:53 +0100
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Sylvain Viollon
date: Wed Nov 06 17:23:44 2013 +0100
revision: 253:688cf3a9fa41 in silva.core.interfaces
branch: 2.4
details: https://hg.infrae.com/silva.core.interfaces?cmd=changeset;node=688cf3a9fa41
modified: src/silva/core/interfaces/adapters.py src/silva/core/interfaces/content.py src/silva/core/interfaces/errors.py
added:
removed:
log: Extend and refactor some interfaces.
diffstat:
src/silva/core/interfaces/adapters.py | 14 ++++++++++++
src/silva/core/interfaces/content.py | 39 ++++++++++++++++++++++++----------
src/silva/core/interfaces/errors.py | 4 +++
3 files changed, 45 insertions(+), 12 deletions(-)
diffs (136 lines):
diff -r 79347bf90281 -r 688cf3a9fa41 src/silva/core/interfaces/adapters.py
--- a/src/silva/core/interfaces/adapters.py Fri Oct 25 15:55:32 2013 +0200
+++ b/src/silva/core/interfaces/adapters.py Wed Nov 06 17:23:44 2013 +0100
@@ -43,6 +43,7 @@
"""
+# BBB
IZipfileImporter = IZipFileImporter
@@ -458,6 +459,19 @@
"""
+class IGhostManager(Interface):
+
+ def modify(target, identifier=None):
+ """Return a ghost manipulator object to create, modify and
+ update it following a standard API.
+ """
+
+ def validate(target, adding=True):
+ """Validate target is valid for the given ghost object.
+ """
+
+
+
class IIcon(Interface):
"""An icon for a content type.
"""
diff -r 79347bf90281 -r 688cf3a9fa41 src/silva/core/interfaces/content.py
--- a/src/silva/core/interfaces/content.py Fri Oct 25 15:55:32 2013 +0200
+++ b/src/silva/core/interfaces/content.py Wed Nov 06 17:23:44 2013 +0100
@@ -593,7 +593,18 @@
"""
-class IFile(IAsset, IDirectlyRendered):
+class IDownloableAsset(IAsset):
+
+ def get_html_tag(preview=False, request=None, **extra_attributes):
+ """Return an HTML tag that points to the asset.
+ """
+
+ def get_download_url(preview=False, request=None):
+ """Return an URL to download the asset.
+ """
+
+
+class IFile(IDownloableAsset, IDirectlyRendered):
"""Silva File content to encapsulate "downloadable" data
"""
# MANIPULATORS
@@ -625,10 +636,6 @@
# ACCESSORS
- def tag(**kw):
- """Generate a tag to download file content.
- """
-
def get_content_type():
"""Return the file content type as it is send to a visitor
while downloading the file.
@@ -655,11 +662,6 @@
"""Return a file descriptor to access the file data.
"""
- def get_download_url():
- """Obtain the public URL the public could use to download this
- file. Typically it's the URL used in ``tag``.
- """
-
class IZODBFile(IFile):
"""A file stored in ZODB
@@ -676,7 +678,7 @@
"""
-class IImage(IAsset, IDirectlyRendered):
+class IImage(IDownloableAsset, IDirectlyRendered):
"""Silva Image
A Silva Image can be used in a Silva Document. An image stored
@@ -715,7 +717,7 @@
of the image.
"""
- def tag(hires=False, thumbnail=False, request=None, preview=False, **extra_attributes):
+ def get_html_tag(preview=False, request=None, hires=False, thumbnail=False,**extra_attributes):
"""Generate a image tag to render either the original version
(if ``hires`` set to True), or the thumbnail (if ``thumbnail``
set to True) or the web version (by default).
@@ -724,6 +726,14 @@
the image tag as HTML attributes.
"""
+
+ def get_download_url(preview=False, request=None, hires=False, thumbnail=False):
+ """Return an URL to download the corresponding image. If ``hires``
+ is True, the URL to the original version will be returned and
+ if ``thumbnail`` is True the URL to the thumbnail will be returned
+ instead.
+ """
+
def get_crop_box(crop=None):
"""Return a tuple describing the current crop box used to
create the web image. The describe the coordinate of the top
@@ -813,6 +823,11 @@
"""
+class IGhostAsset(IGhostManagable, IAsset, IDirectlyRendered):
+ """Ghost Asset
+ """
+
+
class ISilvaNameChooser(INameChooser):
"""Choose and check name for Silva content
"""
diff -r 79347bf90281 -r 688cf3a9fa41 src/silva/core/interfaces/errors.py
--- a/src/silva/core/interfaces/errors.py Fri Oct 25 15:55:32 2013 +0200
+++ b/src/silva/core/interfaces/errors.py Wed Nov 06 17:23:44 2013 +0100
@@ -28,6 +28,10 @@
__doc__ = _(u"Ghost target should be a container.")
+class AssetInvalidTarget(InvalidTarget):
+ __doc__ = _(u"Ghost target should be an asset.")
+
+
class ContentInvalidTarget(InvalidTarget):
__doc__ = _(u"Ghost target should be a content.")