Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
ResourceRegistries.tools.CSSRegistry.CSSRegistryTool Class Reference
Inheritance diagram for ResourceRegistries.tools.CSSRegistry.CSSRegistryTool:
Inheritance graph
[legend]
Collaboration diagram for ResourceRegistries.tools.CSSRegistry.CSSRegistryTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def storeResource
def clearStylesheets
def compareResources
def finalizeResourceMerging
def finalizeContent
def manage_addStylesheet
def manage_saveStylesheets
def manage_removeStylesheet
def registerStylesheet
def updateStylesheet
def getRenderingOptions
def getCompressionOptions
def getContentType

Public Attributes

 resources

Static Public Attributes

 id = config.CSSTOOLNAME
 meta_type = config.CSSTOOLTYPE
string title = 'CSS Registry'
tuple security = ClassSecurityInfo()
tuple manage_cssForm = PageTemplateFile('www/cssconfig', config.GLOBALS)
tuple manage_cssComposition = PageTemplateFile('www/csscomposition', config.GLOBALS)
tuple manage_options
tuple attributes_to_compare
string filename_base = 'ploneStyles'
string filename_appendix = '.css'
string merged_output_prefix = u''
 cache_duration = config.CSS_CACHE_DURATION
 resource_class = Stylesheet

Private Member Functions

def _compressCSS

Static Private Attributes

 __implements__ = BaseRegistryTool.__implements__

Detailed Description

A Plone registry for managing the linking to css files.

Definition at line 84 of file CSSRegistry.py.


Member Function Documentation

def ResourceRegistries.tools.CSSRegistry.CSSRegistryTool._compressCSS (   self,
  content,
  level = 'safe' 
) [private]

Definition at line 161 of file CSSRegistry.py.

00161 
00162     def _compressCSS(self, content, level='safe'):
00163         if level == 'full':
00164             return CSSPacker('full').pack(content)
00165         elif level == 'safe':
00166             return CSSPacker('safe').pack(content)
00167         else:
00168             return content

Here is the caller graph for this function:

Definition at line 141 of file CSSRegistry.py.

00141 
00142     def clearStylesheets(self):
00143         self.clearResources()

Here is the call graph for this function:

Check if two resources are compatible.

Definition at line 145 of file CSSRegistry.py.

00145 
00146     def compareResources(self, sheet1, sheet2 ):
00147         """Check if two resources are compatible."""
00148         for attr in self.attributes_to_compare:
00149             if getattr(sheet1, attr)() != getattr(sheet2, attr)():
00150                 return False
00151             if 'alternate' in sheet1.getRel():
00152                 return False
00153                 # this part needs a test
00154         return True

Finalize the resource content.

Definition at line 170 of file CSSRegistry.py.

00170 
00171     def finalizeContent(self, resource, content):
00172         """Finalize the resource content."""
00173         compression = resource.getCompression()
00174         if compression != 'none' and not self.getDebugMode():
00175             orig_url = "%s/%s?original=1" % (self.absolute_url(), resource.getId())
00176             content = "/* %s */\n%s" % (orig_url,
00177                                      self._compressCSS(content, compression))
00178 
00179         m = resource.getMedia()
00180         if m:
00181             content = '@media %s {\n%s\n}\n' % (m, content)
00182 
00183         return content

Here is the call graph for this function:

Finalize the resource merging with the previous item.

Definition at line 156 of file CSSRegistry.py.

00156 
00157     def finalizeResourceMerging(self, resource, previtem):
00158         """Finalize the resource merging with the previous item."""
00159         if previtem.getMedia() != resource.getMedia():
00160             previtem.setMedia(None)

Compression methods for use in ZMI forms.

Definition at line 290 of file CSSRegistry.py.

00290 
00291     def getCompressionOptions(self):
00292         """Compression methods for use in ZMI forms."""
00293         return config.CSS_COMPRESSION_METHODS

Return the registry content type.

Definition at line 295 of file CSSRegistry.py.

00295 
00296     def getContentType(self):
00297         """Return the registry content type."""
00298         plone_utils = getToolByName(self, 'plone_utils')
00299         try:
00300             encoding = plone_utils.getSiteEncoding()
00301         except AttributeError:
00302             # For Plone < 2.1
00303             pprop = getToolByName(self, 'portal_properties')
00304             default = 'utf-8'
00305             try:
00306                 encoding = pprop.site_properties.getProperty('default_charset', default)
00307             except AttributeError:
00308                 encoding = default
00309         return 'text/css;charset=%s' % encoding
00310 
00311 
00312 InitializeClass(CSSRegistryTool)

Here is the call graph for this function:

Here is the caller graph for this function:

Rendering methods for use in ZMI forms.

Definition at line 285 of file CSSRegistry.py.

00285 
00286     def getRenderingOptions(self):
00287         """Rendering methods for use in ZMI forms."""
00288         return config.CSS_RENDER_METHODS

def ResourceRegistries.tools.CSSRegistry.CSSRegistryTool.manage_addStylesheet (   self,
  id,
  expression = '',
  media = '',
  rel = 'stylesheet',
  title = '',
  rendering = 'import',
  enabled = False,
  cookable = True,
  compression = 'safe',
  cacheable = True,
  REQUEST = None 
)
Register a stylesheet from a TTW request.

Definition at line 192 of file CSSRegistry.py.

00192 
00193                              cacheable=True, REQUEST=None):
00194         """Register a stylesheet from a TTW request."""
00195         self.registerStylesheet(id, expression, media, rel, title,
00196                                 rendering, enabled, cookable, compression, cacheable)
00197         if REQUEST:
00198             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

Here is the caller graph for this function:

Remove stylesheet from the ZMI.

Definition at line 231 of file CSSRegistry.py.

00231 
00232     def manage_removeStylesheet(self, id, REQUEST=None):
00233         """Remove stylesheet from the ZMI."""
00234         self.unregisterResource(id)
00235         if REQUEST:
00236             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

Save stylesheets from the ZMI.

Updates the whole sequence. For editing and reordering.

Definition at line 200 of file CSSRegistry.py.

00200 
00201     def manage_saveStylesheets(self, REQUEST=None):
00202         """Save stylesheets from the ZMI.
00203 
00204         Updates the whole sequence. For editing and reordering.
00205         """
00206         debugmode = REQUEST.get('debugmode',False)
00207         self.setDebugMode(debugmode)
00208         autogroupingmode = REQUEST.get('autogroupingmode', False)
00209         self.setAutoGroupingMode(autogroupingmode)
00210         records = REQUEST.get('stylesheets')
00211         records.sort(lambda a, b: a.sort - b.sort)
00212         self.resources = ()
00213         stylesheets = []
00214         for r in records:
00215             stylesheet = Stylesheet(r.get('id'),
00216                                     expression=r.get('expression', ''),
00217                                     media=r.get('media', ''),
00218                                     rel=r.get('rel', 'stylesheet'),
00219                                     title=r.get('title', ''),
00220                                     rendering=r.get('rendering', 'import'),
00221                                     enabled=r.get('enabled', False),
00222                                     cookable=r.get('cookable', False),
00223                                     cacheable=r.get('cacheable', False),
00224                                     compression=r.get('compression', 'safe'))
00225             stylesheets.append(stylesheet)
00226         self.resources = tuple(stylesheets)
00227         self.cookResources()
00228         if REQUEST:
00229             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

def ResourceRegistries.tools.CSSRegistry.CSSRegistryTool.registerStylesheet (   self,
  id,
  expression = '',
  media = '',
  rel = 'stylesheet',
  title = '',
  rendering = 'import',
  enabled = 1,
  cookable = True,
  compression = 'safe',
  cacheable = True,
  skipCooking = False 
)
Register a stylesheet.

Definition at line 245 of file CSSRegistry.py.

00245 
00246                            skipCooking=False):
00247         """Register a stylesheet."""
00248         stylesheet = Stylesheet(id,
00249                                 expression=expression,
00250                                 media=media,
00251                                 rel=rel,
00252                                 title=title,
00253                                 rendering=rendering,
00254                                 enabled=enabled,
00255                                 cookable=cookable,
00256                                 compression=compression,
00257                                 cacheable=cacheable)
00258         self.storeResource(stylesheet, skipCooking=skipCooking)

Here is the call graph for this function:

Here is the caller graph for this function:

def ResourceRegistries.tools.CSSRegistry.CSSRegistryTool.storeResource (   self,
  resource,
  skipCooking = False 
)
Store a resource.

Definition at line 127 of file CSSRegistry.py.

00127 
00128     def storeResource(self, resource, skipCooking=False):
00129         """Store a resource."""
00130         self.validateId(resource.getId(), self.getResources())
00131         resources = list(self.getResources())
00132         if len(resources) and resources[-1].getId() == 'ploneCustom.css':
00133             # ploneCustom.css should be the last item
00134             resources.insert(-1, resource)
00135         else:
00136             resources.append(resource)
00137         self.resources = tuple(resources)
00138         if not skipCooking:
00139             self.cookResources()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 260 of file CSSRegistry.py.

00260 
00261     def updateStylesheet(self, id, **data):
00262         stylesheet = self.getResourcesDict().get(id, None)
00263         if stylesheet is None:
00264             raise ValueError, 'Invalid resource id %s' % (id)
00265         
00266         if data.get('expression', None) is not None:
00267             stylesheet.setExpression(data['expression'])
00268         if data.get('media', None) is not None:
00269             stylesheet.setMedia(data['media'])
00270         if data.get('rel', None) is not None:
00271             stylesheet.setRel(data['rel'])
00272         if data.get('title', None) is not None:
00273             stylesheet.setTitle(data['title'])
00274         if data.get('rendering', None) is not None:
00275             stylesheet.setRendering(data['rendering'])
00276         if data.get('enabled', None) is not None:
00277             stylesheet.setEnabled(data['enabled'])
00278         if data.get('cookable', None) is not None:
00279             stylesheet.setCookable(data['cookable'])
00280         if data.get('compression', None) is not None:
00281             stylesheet.setCompression(data['compression'])
00282         if data.get('cacheable', None) is not None:
00283             stylesheet.setCacheable(data['cacheable'])

Here is the call graph for this function:


Member Data Documentation

ResourceRegistries.tools.CSSRegistry.CSSRegistryTool.__implements__ = BaseRegistryTool.__implements__ [static, private]

Definition at line 94 of file CSSRegistry.py.

Initial value:
('getExpression', 'getCookable',
                             'getCacheable', 'getRel', 'getRendering')

Definition at line 114 of file CSSRegistry.py.

Definition at line 119 of file CSSRegistry.py.

Definition at line 117 of file CSSRegistry.py.

Definition at line 116 of file CSSRegistry.py.

Definition at line 87 of file CSSRegistry.py.

tuple ResourceRegistries.tools.CSSRegistry.CSSRegistryTool.manage_cssComposition = PageTemplateFile('www/csscomposition', config.GLOBALS) [static]

Definition at line 101 of file CSSRegistry.py.

tuple ResourceRegistries.tools.CSSRegistry.CSSRegistryTool.manage_cssForm = PageTemplateFile('www/cssconfig', config.GLOBALS) [static]

Definition at line 100 of file CSSRegistry.py.

Initial value:
(
        {
            'label': 'CSS Registry',
            'action': 'manage_cssForm',
        },
        {
            'label': 'Merged CSS Composition',
            'action': 'manage_cssComposition',
        },
    )

Definition at line 103 of file CSSRegistry.py.

Definition at line 118 of file CSSRegistry.py.

Definition at line 88 of file CSSRegistry.py.

Definition at line 120 of file CSSRegistry.py.

Definition at line 136 of file CSSRegistry.py.

Definition at line 91 of file CSSRegistry.py.

Definition at line 89 of file CSSRegistry.py.


The documentation for this class was generated from the following file: