This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
glasnost/shared/common/VirtualHostsCommon.py

267 lines
8.1 KiB
Python

# -*- coding: iso-8859-15 -*-
# Glasnost
# By: Odile Bénassy <obenassy@entrouvert.com>
# Romain Chantereau <rchantereau@entrouvert.com>
# Nicolas Clapiès <nclapies@easter-eggs.org>
# Pierre-Antoine Dejace <padejace@entrouvert.be>
# Thierry Dulieu <tdulieu@easter-eggs.com>
# Florent Monnier <monnier@codelutin.com>
# Cédric Musso <cmusso@easter-eggs.org>
# Frédéric Péters <fpeters@entrouvert.be>
# Benjamin Poussin <poussin@codelutin.com>
# Emmanuel Raviart <eraviart@entrouvert.com>
# Sébastien Régnier <regnier@codelutin.com>
# Emmanuel Saracco <esaracco@easter-eggs.com>
#
# Copyright (C) 2000, 2001 Easter-eggs & Emmanuel Raviart
# Copyright (C) 2002 Odile Bénassy, Code Lutin, Thierry Dulieu, Easter-eggs,
# Entr'ouvert, Frédéric Péters, Benjamin Poussin, Emmanuel Raviart,
# Emmanuel Saracco & Théridion
# Copyright (C) 2003 Odile Bénassy, Romain Chantereau, Nicolas Clapiès,
# Code Lutin, Pierre-Antoine Dejace, Thierry Dulieu, Easter-eggs,
# Entr'ouvert, Florent Monnier, Cédric Musso, Ouvaton, Frédéric Péters,
# Benjamin Poussin, Rodolphe Quiédeville, Emmanuel Raviart, Sébastien
# Régnier, Emmanuel Saracco, Théridion & Vecam
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
__doc__ = """Glasnost Virtual Hosts Common Models"""
__version__ = '$Revision$'[11:-2]
from ObjectsCommon import AdminCommon, ObjectCommon, ObjectsCommonMixin
class AdminVirtualHostsCommon(AdminCommon):
defaultVirtualHostId = None
defaultVirtualHostId_kind_balloonHelp = N_(
'Select the default virtual host to use on this server')
defaultVirtualHostId_kind_serverRoles = ['virtualhosts']
defaultVirtualHostId_kindName = 'Id'
serverRole = 'virtualhosts'
def getOrderedLayoutSlotNames(self, parentSlot = None):
slotNames = AdminCommon.getOrderedLayoutSlotNames(
self, parentSlot = parentSlot)
slotNames += ['defaultVirtualHostId']
return slotNames
class VirtualHostCommon(ObjectCommon):
"""Virtual host super class used to be inherited with a Mixin Class.
This is the definition of the attributes of a virtual host object.
This object is used by the VirtualHostProxy.
*creationTime*:
+ is a Kind.
+ Set to None.
+ Is public for Xml Rpc.
+ kindName : 'CreationTime'.
*defaultDispatcherId*:
+ is a Kind.
+ Set to None.
+ Is public for Xml Rpc.
+ Is required.
+ KindName : 'Id'
+ **FIXME**: kindName 'Id' should be replaced by DispatcherId or
'String'.
*hostName*:
+ is a Kind.
+ Set to None.
+ Is public for Xml Rpc.
+ Is required.
+ KindName : 'String'
*modificationTime*:
+ is a Kind.
+ Set to None.
+ Is public for Xml Rpc.
+ KindName : 'ModificationTime'
*readersSet*:
+ is a Kind.
+ Set to None.
+ Is public for Xml Rpc.
+ KindName : 'ReadersSet'
*serverRole*:
The server name string that manage theses objects isntances. Default :
'virtualhosts'
*templateDirectoryName*:
+ is a Kind.
+ Set to 'glasnost2'.
+ Is public for Xml Rpc.
+ Is required.
+ KindName : 'Choice'
*title*:
+ is a Kind.
+ Set to None.
+ Is public for Xml Rpc.
+ Is required.
+ KindName : 'String'
*writersSet*:
+ is a Kind.
+ Set to None.
+ Is public for Xml Rpc.
+ KindName : 'WritersSet'
"""
creationTime = None
creationTime_kindName = 'CreationTime'
defaultDispatcherId = None
defaultDispatcherId_kind_balloonHelp = N_(
'Enter the Glasnost dispatcher id for this virtual host '\
'(you may have to consult your administrator).')
defaultDispatcherId_kind_isRequired = 1
defaultDispatcherId_kindName = 'DispatcherId'
hostName = None
hostName_kind_balloonHelp = N_('Enter the host name.')
hostName_kind_isRequired = 1
hostName_kindName = 'String'
modificationTime = None
modificationTime_kindName = 'ModificationTime'
readersSet = None
readersSet_kindName = 'ReadersSet'
serverRole = 'virtualhosts'
templateDirectoryName = 'glasnost2'
templateDirectoryName_kind_balloonHelp = N_(
'Select the template (skin) to use for this host.')
templateDirectoryName_kind_isRequired = 1
templateDirectoryName_kindName = 'Choice'
title = None
title_kind_balloonHelp = N_('Enter the title of this virtual host.')
title_kind_isRequired = 1
title_kindName = 'String'
writersSet = None
writersSet_kindName = 'WritersSet'
def getLabel(self):
"""Return the virtual host title name string.
Return the title strin attribute.
If the title string is None, an empty string is returned.
"""
label = self.getTitle()
if label is None:
return ''
return label
def getOrderedLayoutSlotNames(self, parentSlot = None):
"""Return the layout slots names sequences.
The layout slots names of the parent are taken, and to them, the
class slot names are added.
Keyword argument
================
*parentSlot*:
The slot where the object is instanciated.
Return the slot names sequence, minimum slot names are the current
object slots.
"""
slotNames = ObjectCommon.getOrderedLayoutSlotNames(
self, parentSlot = parentSlot)
slotNames += [
'title', 'defaultDispatcherId', 'hostName',
'templateDirectoryName', 'creationTime', 'modificationTime',
'writersSet', 'readersSet']
return slotNames
def getTitle(self):
"""Return the title attribute."""
return self.title
class VirtualHostsCommonMixin(ObjectsCommonMixin):
"""Abstract class designed to be inherited with another class.
The product of a multiple inheritance is a fonctionnal Virtual host
server/proxy.
All methods can be overriden or extended, in fact, this class define their
default behavior.
Attributes:
===========
*adminClassName*:
The class name string used for administrative purposes.
*newObjectNameCapitalized*:
The illustrating string explaining what do a new object creation.
The objects are the objects handled by the subclass (not the class
itself).
*objectClassName*:
The handled object class name string.
*objectName*:
The 'gettextized' handled object class name string.
*objectNameCapitalized*:
The capitalized 'gettextized' handled object class name string.
*objectsName*:
The 'gettextized' functionnal class name string (Usualy the class name
without the type (proxy or server, etc...)).
*objectsNameCapitalized*:
The capitalized 'gettextized' class name string (Usualy the class name
without the type (proxy or server, etc...)).
*serverRole*:
The class server role string.
"""
adminClassName = 'AdminVirtualHosts'
newObjectNameCapitalized = N_('New Virtual Host')
objectClassName = 'VirtualHost'
objectName = N_('virtual host')
objectNameCapitalized = N_('Virtual Host')
objectsName = N_('virtual hosts')
objectsNameCapitalized = N_('Virtual Hosts')
serverRole = 'virtualhosts'