Ajout de la notion d'hôte virtuel help, de la même manière qu'il y avait

déjà un hôte virtuel system.

L'aide est toujours accessible depuis n'importe quel hôte virtuel en faisant
http://nom_du_site/help/..., par exemple http://nom_du_site/help/articles/1.
Dans ce cas, elle est affichée avec sa propre template "help" et non avec la
template de l'hôte virtuel.

Reste à modifier la template help pour qu'elle marche dans ces conditions.
This commit is contained in:
eraviart 2003-12-24 09:25:03 +00:00
parent 85cfa39525
commit 3f97db9ac7
11 changed files with 121 additions and 38 deletions

View File

@ -92,7 +92,7 @@ SERVER_GROUP=root
WEB_USER=www-data WEB_USER=www-data
WEB_GROUP=www-data WEB_GROUP=www-data
TEMPLATES=default april bxlug codelutin.org cuisine easter-eggs entrouvert.com entrouvert2 glasnost2 lightbulb macfly plane september vecam theridion entrouvert.be labor-liber.net glasnost.entrouvert.org watercolor skelblue TEMPLATES=default april bxlug codelutin.org cuisine demo.entrouvert.org easter-eggs entrouvert.com entrouvert2 help glasnost2 lightbulb macfly plane september vecam theridion entrouvert.be labor-liber.net glasnost.entrouvert.org watercolor skelblue
RPM_PACKAGE_NAME=python$(PYTHON_VERSION)-tal python$(PYTHON_VERSION)-imaging python$(PYTHON_VERSION)-docutils RPM_PACKAGE_NAME=python$(PYTHON_VERSION)-tal python$(PYTHON_VERSION)-imaging python$(PYTHON_VERSION)-docutils
@ -179,6 +179,7 @@ dist: dist-clean
rm -rf $(PROJECT_DIR) rm -rf $(PROJECT_DIR)
dist-clean: dist-clean:
rm -rf help/data
rm -rf system/data rm -rf system/data
$(FIND) . -name "*~" | xargs -r rm $(FIND) . -name "*~" | xargs -r rm
$(FIND) . -name ".*~" | xargs -r rm $(FIND) . -name ".*~" | xargs -r rm

View File

@ -145,14 +145,25 @@ def doLogRotate():
os.kill(process, signal.SIGHUP) os.kill(process, signal.SIGHUP)
def doMakeHelp(sourceDispatcher):
helpServers = ['articles', 'atoms', 'cards', 'pagenames',
'groups', 'rubrics', 'translations', 'uploadfiles']
for server in servers:
serverFileName = '%s/servers/%s/%s.py' % (
glasnostPythonDir, server, server)
L = [serverFileName, '-s', 'glasnost://%s' % sourceDispatcher,
'-d', 'glasnost://help', '-y', repr(helpServers)]
rc = os.spawnvpe(os.P_WAIT, serverFileName, L, os.environ)
def doMakeSystem(sourceDispatcher): def doMakeSystem(sourceDispatcher):
systemServers = ['articles', 'atoms', 'cards', 'pagenames', systemServers = ['articles', 'atoms', 'cards', 'pagenames',
'groups', 'rubrics', 'translations', 'uploadfiles'] 'groups', 'rubrics', 'translations', 'uploadfiles']
for server in servers: for server in servers:
serverFileName = '%s/servers/%s/%s.py' % ( serverFileName = '%s/servers/%s/%s.py' % (
glasnostPythonDir, server, server) glasnostPythonDir, server, server)
L = [serverFileName, '-s', 'glasnost://%s' % sourceDispatcher, \ L = [serverFileName, '-s', 'glasnost://%s' % sourceDispatcher,
'-y', repr(systemServers)] '-d', 'glasnost://system', '-y', repr(systemServers)]
rc = os.spawnvpe(os.P_WAIT, serverFileName, L, os.environ) rc = os.spawnvpe(os.P_WAIT, serverFileName, L, os.environ)
@ -239,11 +250,12 @@ def doCleanTal(directory):
os.remove(file) os.remove(file)
def doUsage(): def doUsage():
print """usage: %s [-v] (start|stop|make-system|export|import|convert-ids)""" % \ print """usage: %s [-v] (start|stop|make-help|make-system|export|import|convert-ids)""" % \
sys.argv[0] sys.argv[0]
print """ print """
start start Glasnost servers start start Glasnost servers
stop stop Glasnost servers stop stop Glasnost servers
make-help $1 create glasnost://help from glasnost://$1
make-system $1 create glasnost://system from glasnost://$1 make-system $1 create glasnost://system from glasnost://$1
export $1 export glasnost://$1 export $1 export glasnost://$1
import $1 import glasnost://$1 import $1 import glasnost://$1
@ -315,6 +327,8 @@ elif sys.argv[1] == 'stop-one':
doStopOne(sys.argv[2]) doStopOne(sys.argv[2])
elif sys.argv[1] == 'restart-one': elif sys.argv[1] == 'restart-one':
doRestartOne(sys.argv[2]) doRestartOne(sys.argv[2])
elif sys.argv[1] == 'make-help':
doMakeHelp(sys.argv[2])
elif sys.argv[1] == 'make-system': elif sys.argv[1] == 'make-system':
doMakeSystem(sys.argv[2]) doMakeSystem(sys.argv[2])
elif sys.argv[1] == 'export': elif sys.argv[1] == 'export':

View File

@ -232,6 +232,7 @@ class Application(applications.Application):
dispatcherId = None, dispatcherId = None,
fallbackTemplatesDirectoryPath = None, fallbackTemplatesDirectoryPath = None,
function = None, function = None,
helpInUrl = 0,
htmlHeaders = [], htmlHeaders = [],
httpHostName = None, httpHostName = None,
httpLocalPath = None, httpLocalPath = None,
@ -359,17 +360,27 @@ class Application(applications.Application):
cache.checkCachedValues() cache.checkCachedValues()
virtualHost = None virtualHost = None
virtualHostsWeb = getWebForServerRole('virtualhosts') splitedHttpLocalPath = [x for x in httpLocalPath.split('/') if x]
try: if splitedHttpLocalPath and splitedHttpLocalPath[0] == 'help':
virtualHost = virtualHostsWeb.getObjectByHostName(httpHostName) import glasnost.web.VirtualHostsWeb as VirtualHostsWeb
except faults.MissingItem: virtualHost = VirtualHostsWeb.VirtualHost()
if context.getVar('debug'): virtualHost.title = N_('Glasnost Help')
raise 'No Virtual Host defined for %s' % httpHostName virtualHost.hostName = 'help'
return HTTP_NOT_FOUND virtualHost.defaultDispatcherId = 'glasnost://help'
except (faults.UnknownDispatcherInId, faults.UnknownServerId): virtualHost.templateDirectoryName = 'help'
if context.getVar('debug'): virtualHost.language = 'en'
raise else:
return HTTP_SERVICE_UNAVAILABLE virtualHostsWeb = getWebForServerRole('virtualhosts')
try:
virtualHost = virtualHostsWeb.getObjectByHostName(httpHostName)
except faults.MissingItem:
if context.getVar('debug'):
raise 'No Virtual Host defined for %s' % httpHostName
return HTTP_NOT_FOUND
except (faults.UnknownDispatcherInId, faults.UnknownServerId):
if context.getVar('debug'):
raise
return HTTP_SERVICE_UNAVAILABLE
context.setVar('virtualHost', virtualHost) context.setVar('virtualHost', virtualHost)
self.loadWebConfigOptions() self.loadWebConfigOptions()
@ -782,6 +793,9 @@ class Application(applications.Application):
def parseHttpPath(self, remaining): def parseHttpPath(self, remaining):
context.push() context.push()
try: try:
result = self.parseHttpPathHelp(remaining)
if result is not None:
return result
result = self.parseHttpPathRemote(remaining) result = self.parseHttpPathRemote(remaining)
if result is not None: if result is not None:
return result return result
@ -898,6 +912,39 @@ class Application(applications.Application):
finally: finally:
context.pull() context.pull()
def parseHttpPathHelp(self, remaining):
context.push()
try:
assert context.getVar('serverRole') is None
if len(remaining) < 1:
return None
if remaining[0] != 'help':
return None
context.setVar('helpInUrl', 1)
remaining = remaining[1:]
result = self.parseHttpPathLanguage(remaining)
if result is not None:
return result
result = self.parseHttpPathWorkspace(remaining)
if result is not None:
return result
result = self.parseHttpPathAlias(remaining)
if result is not None:
return result
result = self.parseHttpPathServerRole(remaining)
if result is not None:
return result
result = self.parseHttpPathTalFile(remaining)
if result is not None:
return result
result = self.parseHttpPathModule(remaining)
if result is not None:
return result
return None
finally:
context.pull()
def parseHttpPathId(self, remaining): def parseHttpPathId(self, remaining):
context.push() context.push()
try: try:
@ -1026,6 +1073,9 @@ class Application(applications.Application):
'glasnost://%s' % dispatcherHostName) 'glasnost://%s' % dispatcherHostName)
remaining = remaining[2:] remaining = remaining[2:]
result = self.parseHttpPathHelp(remaining)
if result is not None:
return result
result = self.parseHttpPathLanguage(remaining) result = self.parseHttpPathLanguage(remaining)
if result is not None: if result is not None:
return result return result

View File

@ -141,13 +141,14 @@ class DispatcherVirtualServer(VirtualServer):
VirtualServer.init(self) VirtualServer.init(self)
self.applicationTokens = {} self.applicationTokens = {}
self.defaultAccessors = {} self.defaultAccessors = {}
self.dispatcherIds = ['glasnost://system'] self.dispatcherIds = ['glasnost://system', 'glasnost://help']
self.serverAccessors = {} self.serverAccessors = {}
self.serverInfos = {} self.serverInfos = {}
self.virtualServerIds = {} self.virtualServerIds = {}
self.virtualServerIdProfiles = { self.virtualServerIdProfiles = {
'glasnost://help': ['basic', 'cms', 'translations'],
'glasnost://system': ['basic', 'cms', 'translations'], 'glasnost://system': ['basic', 'cms', 'translations'],
} }
class Dispatcher(Server): class Dispatcher(Server):

View File

@ -370,7 +370,8 @@ class IdentitiesServer(commonIdentities.IdentitiesCommonMixin,
def rememberId(self, id): def rememberId(self, id):
virtualServerId = context.getVar('applicationId') virtualServerId = context.getVar('applicationId')
if virtualServerId == 'glasnost://system/identities': if virtualServerId in ['glasnost://help/identities',
'glasnost://system/identities']:
return return
virtualServer = self.getVirtualServer(virtualServerId) virtualServer = self.getVirtualServer(virtualServerId)
userId = self.getUserId() userId = self.getUserId()

View File

@ -109,7 +109,13 @@ class PageNamesServer(PageNamesCommonMixin, ObjectsServer):
for objectId, object in virtualServer.objects.items(): for objectId, object in virtualServer.objects.items():
if object.name == name: if object.name == name:
return object.mappedId return object.mappedId
# Id not found. Look for it into the system virtual server. # Id not found. Look for it into help virtual server.
virtualServerId = 'glasnost://help/%s' % self.applicationRole
virtualServer = self.getVirtualServer(virtualServerId)
for objectId, object in virtualServer.objects.items():
if object.name == name:
return object.mappedId
# Id not found. Look for it into system virtual server.
virtualServerId = 'glasnost://system/%s' % self.applicationRole virtualServerId = 'glasnost://system/%s' % self.applicationRole
virtualServer = self.getVirtualServer(virtualServerId) virtualServer = self.getVirtualServer(virtualServerId)
for objectId, object in virtualServer.objects.items(): for objectId, object in virtualServer.objects.items():
@ -123,7 +129,13 @@ class PageNamesServer(PageNamesCommonMixin, ObjectsServer):
for objectId, object in virtualServer.objects.items(): for objectId, object in virtualServer.objects.items():
if object.name == name: if object.name == name:
return object.id return object.id
# Id not found. Look for it into the system virtual server. # Id not found. Look for it into help virtual server.
virtualServerId = 'glasnost://help/%s' % self.applicationRole
virtualServer = self.getVirtualServer(virtualServerId)
for objectId, object in virtualServer.objects.items():
if object.name == name:
return object.id
# Id not found. Look for it into system virtual server.
virtualServerId = 'glasnost://system/%s' % self.applicationRole virtualServerId = 'glasnost://system/%s' % self.applicationRole
virtualServer = self.getVirtualServer(virtualServerId) virtualServer = self.getVirtualServer(virtualServerId)
for objectId, object in virtualServer.objects.items(): for objectId, object in virtualServer.objects.items():
@ -137,7 +149,13 @@ class PageNamesServer(PageNamesCommonMixin, ObjectsServer):
for objectId, object in virtualServer.objects.items(): for objectId, object in virtualServer.objects.items():
if object.mappedId == mappedId: if object.mappedId == mappedId:
return object.name return object.name
# Name not found. Look for it into the system virtual server. # Name not found. Look for it into help virtual server.
virtualServerId = 'glasnost://help/%s' % self.applicationRole
virtualServer = self.getVirtualServer(virtualServerId)
for objectId, object in virtualServer.objects.items():
if object.mappedId == mappedId:
return object.name
# Name not found. Look for it into system virtual server.
virtualServerId = 'glasnost://system/%s' % self.applicationRole virtualServerId = 'glasnost://system/%s' % self.applicationRole
virtualServer = self.getVirtualServer(virtualServerId) virtualServer = self.getVirtualServer(virtualServerId)
for objectId, object in virtualServer.objects.items(): for objectId, object in virtualServer.objects.items():

View File

@ -589,7 +589,7 @@ class TranslationsServer(TranslationsCommonMixin, AdministrableServerMixin,
virtualServer.lock.release() virtualServer.lock.release()
virtualServer.markCoreAsDirty() virtualServer.markCoreAsDirty()
elif not ignoreNew: elif not ignoreNew:
if virtualServerId == 'glasnost://system': if virtualServerId in ['glasnost://help', 'glasnost://system']:
return ('', '', 'ignored') # or use gettext ? return ('', '', 'ignored') # or use gettext ?
# Check that the string exists on the server before creating its # Check that the string exists on the server before creating its

View File

@ -524,16 +524,12 @@ class rootUrl(httpUrl):
dispatcherHostName = None dispatcherHostName = None
dispatcherPort = None dispatcherPort = None
if self.dispatcherHostName == 'system' or ( if self.dispatcherHostName in ['help', 'system'] or (
(self.dispatcherHostName is None (self.dispatcherHostName is None
or self.dispatcherHostName == dispatcherHostName) or self.dispatcherHostName == dispatcherHostName)
and (self.dispatcherPort is None and (self.dispatcherPort is None
or self.dispatcherPort == dispatcherPort)): or self.dispatcherPort == dispatcherPort)):
if context.getVar('languageSetInUrl') and \ result = httpScriptDirectoryPath
not 'ignoreLanguage' in keywords.keys():
return httpScriptDirectoryPath + \
context.getVar('readLanguages')[0] + '/'
return httpScriptDirectoryPath
else: else:
if self.dispatcherHostName is not None: if self.dispatcherHostName is not None:
dispatcherHostName = self.dispatcherHostName dispatcherHostName = self.dispatcherHostName
@ -549,10 +545,12 @@ class rootUrl(httpUrl):
dispatcherHostName, dispatcherPort) dispatcherHostName, dispatcherPort)
result = '%sremote/%s/' % ( result = '%sremote/%s/' % (
httpScriptDirectoryPath, dispatcherHostNameAndPort) httpScriptDirectoryPath, dispatcherHostNameAndPort)
if context.getVar('languageSetInUrl') and \ if context.getVar('helpInUrl'):
not 'ignoreLanguage' in keywords.keys(): result = '%shelp/' % result
result += context.getVar('readLanguages')[0] + '/' if context.getVar('languageSetInUrl') \
return result and not 'ignoreLanguage' in keywords.keys():
result = '%s%s/' % (result, context.getVar('readLanguages')[0])
return result
class aliasUrl(rootUrl): class aliasUrl(rootUrl):

View File

@ -599,7 +599,7 @@ def getDispatcherAccessor(dispatcherId):
dispatcherHostNameAndPort = extractApplicationHostNameAndPort(dispatcherId) dispatcherHostNameAndPort = extractApplicationHostNameAndPort(dispatcherId)
dispatcherInfos = dispatcherHostNameAndPort.split(':', 1) dispatcherInfos = dispatcherHostNameAndPort.split(':', 1)
dispatcherHostName = dispatcherInfos[0] dispatcherHostName = dispatcherInfos[0]
if dispatcherHostName == 'system': if dispatcherHostName in ['help', 'system']:
dispatcherHostName = context.getVar('dispatcherHostName') dispatcherHostName = context.getVar('dispatcherHostName')
if len(dispatcherInfos) < 2: if len(dispatcherInfos) < 2:
dispatcherPort = context.getVar('dispatcherPort') dispatcherPort = context.getVar('dispatcherPort')

View File

@ -1260,7 +1260,8 @@ class ObjectsProxy(ObjectsCommonMixin, AdministrableProxyMixin, Proxy):
defaultDispatcherId = context.getVar('defaultDispatcherId') defaultDispatcherId = context.getVar('defaultDispatcherId')
dispatcherId = context.getVar('dispatcherId') dispatcherId = context.getVar('dispatcherId')
if not commonTools.extractDispatcherId(objectId) in [ if not commonTools.extractDispatcherId(objectId) in [
defaultDispatcherId, dispatcherId, 'glasnost://system']: defaultDispatcherId, dispatcherId, 'glasnost://help',
'glasnost://system']:
for id, label in labels.items(): for id, label in labels.items():
label += _(' (at <%s>)') \ label += _(' (at <%s>)') \
% extractApplicationHostNameAndPort(objectId) % extractApplicationHostNameAndPort(objectId)
@ -1323,7 +1324,8 @@ class ObjectsProxy(ObjectsCommonMixin, AdministrableProxyMixin, Proxy):
defaultDispatcherId = context.getVar('defaultDispatcherId') defaultDispatcherId = context.getVar('defaultDispatcherId')
dispatcherId = context.getVar('dispatcherId') dispatcherId = context.getVar('dispatcherId')
if not commonTools.extractDispatcherId(objectId) in [ if not commonTools.extractDispatcherId(objectId) in [
defaultDispatcherId, dispatcherId, 'glasnost://system']: defaultDispatcherId, dispatcherId, 'glasnost://help',
'glasnost://system']:
labelTranslated += _(' (at <%s>)') \ labelTranslated += _(' (at <%s>)') \
% extractApplicationHostNameAndPort(objectId) % extractApplicationHostNameAndPort(objectId)
return labelTranslated return labelTranslated

View File

@ -1050,8 +1050,6 @@ class Server(things.BaseThing, applications.Application):
virtualServer.markAllAsDirtyFIXME() virtualServer.markAllAsDirtyFIXME()
virtualServer.savePendingRequests() virtualServer.savePendingRequests()
return 0 return 0
if doSystem:
destinationDispatcherId = 'glasnost://system'
if sourceDispatcherId and destinationDispatcherId: if sourceDispatcherId and destinationDispatcherId:
# Convert all the ids from sourceDispatcherId to # Convert all the ids from sourceDispatcherId to
# destinationDispatcherId. # destinationDispatcherId.
@ -1627,7 +1625,7 @@ class AdministrableServerMixin:
virtualServerId = context.getVar('applicationId') virtualServerId = context.getVar('applicationId')
dispatcherId = commonTools.extractDispatcherId(virtualServerId) dispatcherId = commonTools.extractDispatcherId(virtualServerId)
if dispatcherId == 'glasnost://system': if dispatcherId in ['glasnost://help', 'glasnost://system']:
return 0 return 0
virtualServer = self.getVirtualServer(virtualServerId) virtualServer = self.getVirtualServer(virtualServerId)
admin = virtualServer.admin admin = virtualServer.admin