Author: jmorliaguet Date: Sun Apr 23 14:35:50 2006 New Revision: 2946 Modified: cpsskins/branches/paris-sprint-2006/ui/manager/views.py cpsskins/branches/paris-sprint-2006/utils.py Log:
- moved addThemeSkeleton to cpsskins.utils Modified: cpsskins/branches/paris-sprint-2006/ui/manager/views.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/ui/manager/views.py (original) +++ cpsskins/branches/paris-sprint-2006/ui/manager/views.py Sun Apr 23 14:35:50 2006 @@ -17,20 +17,12 @@ """ __docformat__ = "reStructuredText" -import urllib - from zope.app import zapi from zope.interface import implements, Interface -from cpsskins.browser.negotiation.interfaces import INegotiation -from cpsskins.elements.interfaces import IDisplayable, IFormattable from cpsskins.elements.theme import Theme -from cpsskins.elements.themepage import ThemePage -from cpsskins.elements.pageblock import PageBlock -from cpsskins.elements.cell import Cell -from cpsskins.elements.slot import Slot from cpsskins.ui.authoring.views import IAuthoring -from cpsskins.utils import getThemeManager +from cpsskins.utils import getThemeManager, addThemeSkeleton class IThemeManagerView(Interface): @@ -83,41 +75,7 @@ """Creates a theme skeleton (mostly for demo purposes until some theme export / import functionality is available). """ - theme = Theme() - name= self.context.addTheme(theme) - theme.title = name.replace('-', ' ') - - # Add a page - theme[u'page'] = ThemePage(u'Default page') - # Add the page blocks - theme[u'page'][u'top'] = PageBlock(u'Top') - theme[u'page'][u'main'] = PageBlock(u'Main') - theme[u'page'][u'bottom'] = PageBlock(u'Bottom') - # Add the cells - theme[u'page'][u'top'][u'main'] = Cell(u'Top') - theme[u'page'][u'main'][u'left'] = Cell(u'Left') - theme[u'page'][u'main'][u'main'] = Cell(u'Main') - theme[u'page'][u'main'][u'right'] = Cell(u'Right') - theme[u'page'][u'bottom'][u'bottom'] = Cell(u'Bottom') - # Add the slots - theme[u'page'][u'main'][u'left'][u'left'] = Slot(u'Left slot', u'', - u'left') - theme[u'page'][u'main'][u'right'][u'right'] = Slot(u'Right slot', u'', - u'right') - - # Some basic layout formatting - def set_width(element, width): - IFormattable( - IDisplayable(element).getDisplay() - ).getFormat(u'layout')[u'width'] = width - - set_width(theme[u'page'][u'top'], u'100%') - set_width(theme[u'page'][u'main'], u'100%') - set_width(theme[u'page'][u'bottom'], u'100%') - - set_width(theme[u'page'][u'main'][u'left'], u'20%') - set_width(theme[u'page'][u'main'][u'main'], u'60%') - set_width(theme[u'page'][u'main'][u'right'], u'20%') + addThemeSkeleton(self.context) # set as the default theme if len(self.getThemes()) == 1: Modified: cpsskins/branches/paris-sprint-2006/utils.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/utils.py (original) +++ cpsskins/branches/paris-sprint-2006/utils.py Sun Apr 23 14:35:50 2006 @@ -17,10 +17,9 @@ """ __docformat__ = "reStructuredText" -from zope.component import queryUtility, getUtility, getSiteManager +from zope.component import getSiteManager from zope.app.zapi import getParent -from cpsskins.setup.interfaces import IResourceManager from cpsskins.thememanager import IThemeManagementFolder def getThemeManager(context): @@ -36,4 +35,49 @@ return None +def addThemeSkeleton(context): + # for testing purposes + from cpsskins.elements.interfaces import IDisplayable, IFormattable + from cpsskins.elements.theme import Theme + from cpsskins.elements.themepage import ThemePage + from cpsskins.elements.pageblock import PageBlock + from cpsskins.elements.cell import Cell + from cpsskins.elements.slot import Slot + + theme = Theme() + name= context.addTheme(theme) + theme.title = name.replace('-', ' ') + + # Add a page + theme[u'page'] = ThemePage(u'Default page') + # Add the page blocks + theme[u'page'][u'top'] = PageBlock(u'Top') + theme[u'page'][u'main'] = PageBlock(u'Main') + theme[u'page'][u'bottom'] = PageBlock(u'Bottom') + # Add the cells + theme[u'page'][u'top'][u'main'] = Cell(u'Top') + theme[u'page'][u'main'][u'left'] = Cell(u'Left') + theme[u'page'][u'main'][u'main'] = Cell(u'Main') + theme[u'page'][u'main'][u'right'] = Cell(u'Right') + theme[u'page'][u'bottom'][u'bottom'] = Cell(u'Bottom') + # Add the slots + theme[u'page'][u'main'][u'left'][u'left'] = Slot(u'Left slot', u'', + u'left') + theme[u'page'][u'main'][u'right'][u'right'] = Slot(u'Right slot', u'', + u'right') + + # Some basic layout formatting + def set_width(element, width): + IFormattable( + IDisplayable(element).getDisplay() + ).getFormat(u'layout')[u'width'] = width + + set_width(theme[u'page'][u'top'], u'100%') + set_width(theme[u'page'][u'main'], u'100%') + set_width(theme[u'page'][u'bottom'], u'100%') + + set_width(theme[u'page'][u'main'][u'left'], u'20%') + set_width(theme[u'page'][u'main'][u'main'], u'60%') + set_width(theme[u'page'][u'main'][u'right'], u'20%') + return theme -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins