Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
CMFCore.SkinsTool.SkinsTool Class Reference
Inheritance diagram for CMFCore.SkinsTool.SkinsTool:
Inheritance graph
[legend]
Collaboration diagram for CMFCore.SkinsTool.SkinsTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def manage_skinLayers
def isFirstInSkin
def manage_properties
def PUT_factory
def testSkinPath
def getSkinPath
def getDefaultSkin
def getRequestVarname
def getAllowAny
def getCookiePersistence
def getSkinPaths
def getSkinSelections
def updateSkinCookie
def clearSkinCookie
def addSkinSelection

Public Attributes

 default_skin
 request_varname
 allow_any
 cookie_persistence

Static Public Attributes

string id = 'portal_skins'
string meta_type = 'CMF Skins Tool'
int allow_any = 0
int cookie_persistence = 0
string default_skin = ''
string request_varname = 'portal_skin'
 selections = None
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_overview = DTMLFile( 'explainSkinsTool', _dtmldir )
tuple manage_propertiesForm = DTMLFile('dtml/skinProps', globals())
tuple manage_findResult
tuple manage_findForm
 PUT_factory__replaceable__ = REPLACEABLE

Private Member Functions

def _getSelections

Static Private Attributes

tuple __implements__

Detailed Description

This tool is used to supply skins to a portal.

Definition at line 59 of file SkinsTool.py.


Constructor & Destructor Documentation

Definition at line 84 of file SkinsTool.py.

00084 
00085     def __init__(self):
00086         self.selections = PersistentMapping()


Member Function Documentation

Definition at line 87 of file SkinsTool.py.

00087 
00088     def _getSelections(self):
00089         sels = self.selections
00090         if sels is None:
00091             # Backward compatibility.
00092             self.selections = sels = PersistentMapping()
00093         return sels

Here is the caller graph for this function:

def CMFCore.SkinsTool.SkinsTool.addSkinSelection (   self,
  skinname,
  skinpath,
  test = 0,
  make_default = 0 
)
Adds a skin selection.

Definition at line 352 of file SkinsTool.py.

00352 
00353     def addSkinSelection(self, skinname, skinpath, test=0, make_default=0):
00354         '''
00355         Adds a skin selection.
00356         '''
00357         sels = self._getSelections()
00358         skinpath = str(skinpath)
00359 
00360         # Basic precaution to make sure the stuff we want to ignore in
00361         # DirectoryViews gets prevented from ending up in a skin path
00362         path_elems = [x.strip() for x in skinpath.split(',')]
00363         ignored = base_ignore + ignore
00364 
00365         for elem in path_elems[:]:
00366             if elem in ignored or ignore_re.match(elem):
00367                 path_elems.remove(elem)
00368 
00369         skinpath = ','.join(path_elems)
00370 
00371         if test:
00372             self.testSkinPath(skinpath)
00373         sels[str(skinname)] = skinpath
00374         if make_default:
00375             self.default_skin = skinname
00376 
00377 InitializeClass(SkinsTool)

Here is the call graph for this function:

Expire the skin cookie.

Definition at line 340 of file SkinsTool.py.

00340 
00341     def clearSkinCookie(self):
00342         """ Expire the skin cookie.
00343         """
00344         # XXX: this method violates the rules for tools/utilities:
00345         # it depends on a non-utility tool and uses self.REQUEST
00346         req = self.REQUEST
00347         resp = req.RESPONSE
00348         utool = getToolByName(self, 'portal_url')
00349         portal_path = req['BASEPATH1'] + '/' + utool(1)
00350         resp.expireCookie(self.request_varname, path=portal_path)

Here is the call graph for this function:

Used by the management UI.  Returns a flag indicating whether
users are allowed to use arbitrary skin paths.

Definition at line 263 of file SkinsTool.py.

00263 
00264     def getAllowAny(self):
00265         '''
00266         Used by the management UI.  Returns a flag indicating whether
00267         users are allowed to use arbitrary skin paths.
00268         '''
00269         return self.allow_any

Used by the management UI.  Returns a flag indicating whether
the skins cookie is persistent or not.

Definition at line 271 of file SkinsTool.py.

00271 
00272     def getCookiePersistence(self):
00273         '''
00274         Used by the management UI.  Returns a flag indicating whether
00275         the skins cookie is persistent or not.
00276         '''
00277         return self.cookie_persistence

Get the default skin name.

Definition at line 248 of file SkinsTool.py.

00248 
00249     def getDefaultSkin(self):
00250         """ Get the default skin name.
00251         """
00252         return self.default_skin

Here is the caller graph for this function:

Get the variable name to look for in the REQUEST.

Definition at line 254 of file SkinsTool.py.

00254 
00255     def getRequestVarname(self):
00256         """ Get the variable name to look for in the REQUEST.
00257         """
00258         return self.request_varname

def CMFCore.SkinsTool.SkinsTool.getSkinPath (   self,
  name 
)
Convert a skin name to a skin path.

Definition at line 237 of file SkinsTool.py.

00237 
00238     def getSkinPath(self, name):
00239         """ Convert a skin name to a skin path.
00240         """
00241         sels = self._getSelections()
00242         p = sels.get(name, None)
00243         if p is None:
00244             if self.allow_any:
00245                 return name
00246         return p  # Can be None

Here is the call graph for this function:

Here is the caller graph for this function:

Used by the management UI.  Returns the list of skin name to
skin path mappings as a sorted list of tuples.

Definition at line 279 of file SkinsTool.py.

00279 
00280     def getSkinPaths(self):
00281         '''
00282         Used by the management UI.  Returns the list of skin name to
00283         skin path mappings as a sorted list of tuples.
00284         '''
00285         sels = self._getSelections()
00286         rval = []
00287         for key, value in sels.items():
00288             rval.append((key, value))
00289         rval.sort()
00290         return rval

Here is the call graph for this function:

Get the sorted list of available skin names.

Definition at line 295 of file SkinsTool.py.

00295 
00296     def getSkinSelections(self):
00297         """ Get the sorted list of available skin names.
00298         """
00299         sels = self._getSelections()
00300         rval = list(sels.keys())
00301         rval.sort()
00302         return rval

Here is the call graph for this function:

def CMFCore.SkinsTool.SkinsTool.isFirstInSkin (   self,
  template_path,
  skin = None 
)
Is the specified template the one that would get returned from the current
skin?

Definition at line 151 of file SkinsTool.py.

00151 
00152     def isFirstInSkin(self, template_path, skin=None):
00153         """
00154         Is the specified template the one that would get returned from the current
00155         skin?
00156         """
00157         if skin is None or skin == 'None':
00158             skin = self.getDefaultSkin()
00159         template = self.restrictedTraverse(template_path)
00160         name = template.getId()
00161         skin_path = self.getSkinPath(skin)
00162         if not skin_path:
00163             return 0
00164         parts = list(skin_path.split(","))
00165         found = ""
00166         for part in parts:
00167             part = part.strip()
00168             if part[0] == "_":
00169                 continue
00170             partob = getattr(self, part, None)
00171             if partob:
00172                 skin_template = getattr(partob.aq_base, name, None)
00173                 if skin_template:
00174                     found = skin_template
00175                     break
00176         if found == template:
00177             return 1
00178         else:
00179             return 0

Here is the call graph for this function:

def CMFCore.SkinsTool.SkinsTool.manage_properties (   self,
  default_skin = '',
  request_varname = '',
  allow_any = 0,
  chosen = (),
  add_skin = 0,
  del_skin = 0,
  skinname = '',
  skinpath = '',
  cookie_persistence = 0,
  REQUEST = None 
)
Changes portal_skin properties. 

Definition at line 184 of file SkinsTool.py.

00184 
00185                           cookie_persistence=0, REQUEST=None):
00186         """ Changes portal_skin properties. """
00187         self.default_skin = str(default_skin)
00188         self.request_varname = str(request_varname)
00189         self.allow_any = allow_any and 1 or 0
00190         self.cookie_persistence = cookie_persistence and 1 or 0
00191         if REQUEST is not None:
00192             return self.manage_propertiesForm(
00193                 self, REQUEST, management_view='Properties', manage_tabs_message='Properties changed.')

Here is the caller graph for this function:

def CMFCore.SkinsTool.SkinsTool.manage_skinLayers (   self,
  chosen = (),
  add_skin = 0,
  del_skin = 0,
  skinname = '',
  skinpath = '',
  REQUEST = None 
)
Change the skinLayers.

Definition at line 117 of file SkinsTool.py.

00117 
00118                           skinname='', skinpath='', REQUEST=None):
00119         """ Change the skinLayers.
00120         """
00121         sels = self._getSelections()
00122         if del_skin:
00123             for name in chosen:
00124                 del sels[name]
00125 
00126         if REQUEST is not None:
00127             for key in sels.keys():
00128                 fname = 'skinpath_%s' % key
00129                 val = REQUEST[fname]
00130 
00131                 # if val is a list from the new lines field
00132                 # then munge it back into a comma delimited list
00133                 # for hysterical reasons
00134                 if isinstance(val, list):
00135                     val = ','.join([layer.strip() for layer in val])
00136 
00137                 if sels[key] != val:
00138                     self.testSkinPath(val)
00139                     sels[key] = val
00140 
00141         if add_skin:
00142             skinpath = ','.join([layer.strip() for layer in skinpath])
00143             self.testSkinPath(skinpath)
00144             sels[str(skinname)] = skinpath
00145 
00146         if REQUEST is not None:
00147             return self.manage_propertiesForm(
00148                 self, REQUEST, management_view='Properties', manage_tabs_message='Skins changed.')
00149 

Here is the call graph for this function:

def CMFCore.SkinsTool.SkinsTool.PUT_factory (   self,
  name,
  typ,
  body 
)
    Dispatcher for PUT requests to non-existent IDs.  Returns
    an object of the appropriate type (or None, if we don't
    know what to do).

Definition at line 196 of file SkinsTool.py.

00196 
00197     def PUT_factory( self, name, typ, body ):
00198         """
00199             Dispatcher for PUT requests to non-existent IDs.  Returns
00200             an object of the appropriate type (or None, if we don't
00201             know what to do).
00202         """
00203         major, minor = typ.split('/', 1)
00204 
00205         if major == 'image':
00206             return Image( id=name
00207                         , title=''
00208                         , file=''
00209                         , content_type=typ
00210                         )
00211 
00212         if major == 'text':
00213 
00214             if minor == 'x-python':
00215                 return PythonScript( id=name )
00216 
00217             if minor in ('html', 'xml'):
00218                 return ZopePageTemplate( name )
00219 
00220             return DTMLMethod( __name__=name )
00221 
00222         return None

Calls SkinsContainer.getSkinByPath().

Definition at line 228 of file SkinsTool.py.

00228 
00229     def testSkinPath(self, p):
00230         """ Calls SkinsContainer.getSkinByPath().
00231         """
00232         self.getSkinByPath(p, raise_exc=1)

Here is the call graph for this function:

Here is the caller graph for this function:

If needed, updates the skin cookie based on the member preference.

Definition at line 304 of file SkinsTool.py.

00304 
00305     def updateSkinCookie(self):
00306         """ If needed, updates the skin cookie based on the member preference.
00307         """
00308         # XXX: this method violates the rules for tools/utilities:
00309         # it depends on a non-utility tool and uses self.REQUEST
00310         mtool = getToolByName(self, 'portal_membership')
00311         utool = getToolByName(self, 'portal_url')
00312         member = mtool.getAuthenticatedMember()
00313         if hasattr(aq_base(member), 'getProperty'):
00314             mskin = member.getProperty('portal_skin', None)
00315             if mskin:
00316                 req = self.REQUEST
00317                 cookie = req.cookies.get(self.request_varname, None)
00318                 if cookie != mskin:
00319                     resp = req.RESPONSE
00320                     portal_path = req['BASEPATH1'] + '/' + utool(1)
00321 
00322                     if not self.cookie_persistence:
00323                         # *Don't* make the cookie persistent!
00324                         resp.setCookie(self.request_varname, mskin,
00325                                        path=portal_path)
00326                     else:
00327                         expires = ( DateTime( 'GMT' ) + 365 ).rfc822()
00328                         resp.setCookie( self.request_varname
00329                                       , mskin
00330                                       , path=portal_path
00331                                       , expires=expires
00332                                       )
00333                     # Ensure updateSkinCookie() doesn't try again
00334                     # within this request.
00335                     req.cookies[self.request_varname] = mskin
00336                     req[self.request_varname] = mskin
00337                     return 1
00338         return 0

Here is the call graph for this function:


Member Data Documentation

Initial value:
(z2ISkinsTool, SkinsContainer.__implements__,
                      ActionProviderBase.__implements__)

Definition at line 65 of file SkinsTool.py.

Definition at line 70 of file SkinsTool.py.

Definition at line 188 of file SkinsTool.py.

Definition at line 71 of file SkinsTool.py.

Definition at line 189 of file SkinsTool.py.

Definition at line 72 of file SkinsTool.py.

Definition at line 186 of file SkinsTool.py.

string CMFCore.SkinsTool.SkinsTool.id = 'portal_skins' [static]

Definition at line 68 of file SkinsTool.py.

Initial value:
DTMLFile('findForm', _dtmldir,
                               management_view='Find')

Definition at line 110 of file SkinsTool.py.

Initial value:
DTMLFile('findResult', _dtmldir,
                                 management_view='Find')

Definition at line 106 of file SkinsTool.py.

Initial value:
( modifiedOptions() +
                      ({ 'label' : 'Overview', 'action' : 'manage_overview' }
                     ,
                     ) + ActionProviderBase.manage_options
                     )

Definition at line 78 of file SkinsTool.py.

tuple CMFCore.SkinsTool.SkinsTool.manage_overview = DTMLFile( 'explainSkinsTool', _dtmldir ) [static]

Definition at line 98 of file SkinsTool.py.

tuple CMFCore.SkinsTool.SkinsTool.manage_propertiesForm = DTMLFile('dtml/skinProps', globals()) [static]

Definition at line 101 of file SkinsTool.py.

string CMFCore.SkinsTool.SkinsTool.meta_type = 'CMF Skins Tool' [static]

Definition at line 69 of file SkinsTool.py.

Definition at line 224 of file SkinsTool.py.

string CMFCore.SkinsTool.SkinsTool.request_varname = 'portal_skin' [static]

Definition at line 73 of file SkinsTool.py.

Definition at line 187 of file SkinsTool.py.

tuple CMFCore.SkinsTool.SkinsTool.security = ClassSecurityInfo() [static]

Definition at line 76 of file SkinsTool.py.

Definition at line 74 of file SkinsTool.py.


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