Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

ice.adverlet is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
Web
 
Links
License
GPL v.3
============
ice.adverlet
============

.. contents::

Usage
=====

This package - for Zope3 based sites - provides a simple way to edit
any HTML snippet. It includes a WYSIWYG-editor, undo support and
storage for images.

Examples of possible uses include: advertisement portlets,
announcements, footers, frontpages, etc.

The package provides the ZCML directive `adverlet` and TALES
expression `adverlet`.

To use the package follow these 6 simple steps:

1) Include the package:




2) In the ZCML configuration file define all your adverlets, for
example:







Notice:
`name` - Required.
`description` - Not required.
`default` - Not required, it is name of browser view, registered in
zcml-directives like browser:page.
`wysiwyg' - Not required. Defines usage rich-text editor by default for this
adverlet in management UI. User (admin) can change this in the form.
Default value is True.

3) Write `adverlet` TALES expression in to your skin:

where `top` is name of the adverlet. 4) The package provides a view to manage all registered adverlets. This view may be called by a special content provider in any page::
5) This content provider has the permission "ice.adverlet.Manage". Therefore, you need to grant this permission to a role in your project, and allow "undo" for this user, for example:: 6) Install and register 2 local utilities: 1. Factory - ice.adverlet.storage.SourceStorage; Interface - ice.adverlet.interfaces.ISourceStorage; Name - empty. (into Local Site Manager) 2. Factory - ice.adverlet.storage.FileStorage; Interface - ice.adverlet.interfaces.IFileStorage; Name - empty. (into local site) That's it. N.B. You can define your own templates for management UI. To do this, take a look at ice/adverlet/browser/template and write your own adapters in your project for your own templates. You will need to: - Change @adapter(IContentProvider, IDefaultBrowserLayer) to @adapter(IContentProvider, IMyCustomLayer) - Register this adapter with the same name (take a look at ice/adverlet/browser/configure.zcml, section .) N.B. Also, you can use default templates but not default CSS for management UI. For this, look in ZMI `Settings` form for ice.adverlet.storage.SourceStorage local utility or define attribute `defaultCSS=False` in your install-tool code. Tests ===== >>> import zope.interface >>> import zope.component Let's register a default view for one of our adverlets:: >>> import os, tempfile >>> temp_dir = tempfile.mkdtemp() >>> templateFileName = os.path.join(temp_dir, 'default_footer.pt') >>> open(templateFileName, 'w').write(''' ...

Default Footer

... ''') >>> from zope.publisher.interfaces import browser >>> from zope.app.pagetemplate import simpleviewclass >>> DefaultViewClass = simpleviewclass.SimpleViewClass( ... templateFileName, name='default-footer') >>> zope.component.provideAdapter( ... DefaultViewClass, ... (zope.interface.Interface, browser.IDefaultBrowserLayer), ... zope.interface.Interface, ... name='default-footer' ... ) Let's register a few advertlets:: >>> from zope.configuration import xmlconfig >>> import ice.adverlet >>> context = xmlconfig.file('meta.zcml', ice.adverlet) >>> context = xmlconfig.string(''' ... ... ... ... ... ... ... ''', context) Now we can try to call these adverlets in any view:: >>> templateFileName = os.path.join(temp_dir, 'template.pt') >>> open(templateFileName, 'w').write(''' ... ... ...
...
... ... ... ''') >>> PageClass = simpleviewclass.SimpleViewClass( ... templateFileName, name='index.html') >>> zope.component.provideAdapter( ... PageClass, ... (zope.interface.Interface, browser.IDefaultBrowserLayer), ... zope.interface.Interface, ... name='index.html' ... ) >>> from zope.publisher.browser import TestRequest >>> request = TestRequest() >>> class Content(object): ... zope.interface.implements(zope.interface.Interface) >>> content = Content() >>> view = zope.component.getMultiAdapter( ... (content, request), name='index.html') >>> print view().strip()

Default Footer

To edit adverlets store HTML sources:: >>> from ice.adverlet.storage import SourceStorage >>> from ice.adverlet.interfaces import ISourceStorage >>> storage = SourceStorage() >>> ISourceStorage.providedBy(storage) True >>> storage.sources['frontpage'] = u''' ...

OhLoh

... ''' and register storage as utility:: >>> zope.component.provideUtility(storage, ISourceStorage) Let's check the test view now:: >>> print view().strip() Then we will test image storage and image wrapper. To do this, let's register storage for the files:: >>> from ice.adverlet.storage import FileStorage >>> from ice.adverlet.interfaces import IFileStorage >>> files = FileStorage() >>> IFileStorage.providedBy(files) True >>> zope.component.provideUtility(files, IFileStorage) And let's try to use the image wrapper to store images in this storage:: >>> from ice.adverlet.image import ImageWrapper >>> from ice.adverlet.interfaces import IImageWrapper >>> wrapper = ImageWrapper() >>> IImageWrapper.providedBy(wrapper) True Register adapter for DublinCore:: >>> from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter >>> from zope.dublincore.interfaces import IZopeDublinCore >>> from zope.annotation.interfaces import IAttributeAnnotatable >>> from zope.app.file.image import Image >>> zope.interface.classImplements(Image, IAttributeAnnotatable) >>> zope.component.provideAdapter( ... factory = ZDCAnnotatableAdapter, ... provides = IZopeDublinCore, ... adapts = (IAttributeAnnotatable,) ... ) We use test image:: >>> from ice.adverlet.tests.tests import zptlogo >>> wrapper.data = zptlogo >>> wrapper.description = u'Logo image' Now let's check file storage:: >>> [key for key in files.keys()] [u'Image'] >>> [IZopeDublinCore(file).title for file in files.values()] [u'Logo image'] Note that in management UI we use named global utilities IAdverlet for store HTML instead of using the storage directly. Let's test this feature:: >>> storage.sources['frontpage'] u'\n

OhLoh

Let's test `newlines` parameter:: >>> frontpage.newlines = True >>> print view().strip()

Welcome!
You are here.



$(document).ready( function() { $("#pm-install-toggle").click(function() { $("#pm-install-details").toggle(); return false; }); $(".pkg-link-list.jquery-limit").each(function(idx, ul){ var kind = $(ul).parent().parent().find('a').attr('name'); if (window.location.hash == "#" + kind){ return; } var links = $(ul).find('li'); var LIMIT = 5; if (links.length > LIMIT){ // Show only LIMIT items; hide the rest $('li:gt(' + (LIMIT-1) + ')', ul).hide(); // Add a 'see more' link to unhide them $(ul).append('
  • ... see more ('+ (links.length-LIMIT) + ')
  • '); var see_more = $(ul).find('.jquery-limit-see-more'); see_more.click(function(){ links.show(); see_more.hide(); return false; }) } }); $("table#buildmatrix td").click(function(event){ if ($(event.target).attr('href') || $(event.target).parent().attr('href')) // except: clickable elements inside TD return; var buildinfo = $(this).find('.pkg-buildinfo-all'); Shadowbox.open({ content: buildinfo.html(), player: "html", title: buildinfo.attr("title"), height: Math.min(400, buildinfo.outerHeight()), //width: Math.min(600, buildinfo.outerWidth()), width: 600, options: { animate: false, animateFade: false, displayNav: false, overlayOpacity: .2 } }); if (!$.browser.mozilla) $("#sb-body .tiptip").tipTip(); // make tiptips for the now-visible stuff }); $("table#buildmatrix td").click(function(event){ event.stopPropagation(); }); });

    Subscribe to package updates

    What does the lock icon mean?

    Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

    Need custom builds or support?

    ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

    Plan on re-distributing ActivePython?

    Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.