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:
parent
85cfa39525
commit
3f97db9ac7
3
Makefile
3
Makefile
|
@ -92,7 +92,7 @@ SERVER_GROUP=root
|
|||
WEB_USER=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
|
||||
|
||||
|
@ -179,6 +179,7 @@ dist: dist-clean
|
|||
rm -rf $(PROJECT_DIR)
|
||||
|
||||
dist-clean:
|
||||
rm -rf help/data
|
||||
rm -rf system/data
|
||||
$(FIND) . -name "*~" | xargs -r rm
|
||||
$(FIND) . -name ".*~" | xargs -r rm
|
||||
|
|
|
@ -145,14 +145,25 @@ def doLogRotate():
|
|||
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):
|
||||
systemServers = ['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, \
|
||||
'-y', repr(systemServers)]
|
||||
L = [serverFileName, '-s', 'glasnost://%s' % sourceDispatcher,
|
||||
'-d', 'glasnost://system', '-y', repr(systemServers)]
|
||||
rc = os.spawnvpe(os.P_WAIT, serverFileName, L, os.environ)
|
||||
|
||||
|
||||
|
@ -239,11 +250,12 @@ def doCleanTal(directory):
|
|||
os.remove(file)
|
||||
|
||||
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]
|
||||
print """
|
||||
start start Glasnost servers
|
||||
stop stop Glasnost servers
|
||||
make-help $1 create glasnost://help from glasnost://$1
|
||||
make-system $1 create glasnost://system from glasnost://$1
|
||||
export $1 export glasnost://$1
|
||||
import $1 import glasnost://$1
|
||||
|
@ -315,6 +327,8 @@ elif sys.argv[1] == 'stop-one':
|
|||
doStopOne(sys.argv[2])
|
||||
elif sys.argv[1] == 'restart-one':
|
||||
doRestartOne(sys.argv[2])
|
||||
elif sys.argv[1] == 'make-help':
|
||||
doMakeHelp(sys.argv[2])
|
||||
elif sys.argv[1] == 'make-system':
|
||||
doMakeSystem(sys.argv[2])
|
||||
elif sys.argv[1] == 'export':
|
||||
|
|
|
@ -232,6 +232,7 @@ class Application(applications.Application):
|
|||
dispatcherId = None,
|
||||
fallbackTemplatesDirectoryPath = None,
|
||||
function = None,
|
||||
helpInUrl = 0,
|
||||
htmlHeaders = [],
|
||||
httpHostName = None,
|
||||
httpLocalPath = None,
|
||||
|
@ -359,17 +360,27 @@ class Application(applications.Application):
|
|||
cache.checkCachedValues()
|
||||
|
||||
virtualHost = None
|
||||
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
|
||||
splitedHttpLocalPath = [x for x in httpLocalPath.split('/') if x]
|
||||
if splitedHttpLocalPath and splitedHttpLocalPath[0] == 'help':
|
||||
import glasnost.web.VirtualHostsWeb as VirtualHostsWeb
|
||||
virtualHost = VirtualHostsWeb.VirtualHost()
|
||||
virtualHost.title = N_('Glasnost Help')
|
||||
virtualHost.hostName = 'help'
|
||||
virtualHost.defaultDispatcherId = 'glasnost://help'
|
||||
virtualHost.templateDirectoryName = 'help'
|
||||
virtualHost.language = 'en'
|
||||
else:
|
||||
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)
|
||||
|
||||
self.loadWebConfigOptions()
|
||||
|
@ -782,6 +793,9 @@ class Application(applications.Application):
|
|||
def parseHttpPath(self, remaining):
|
||||
context.push()
|
||||
try:
|
||||
result = self.parseHttpPathHelp(remaining)
|
||||
if result is not None:
|
||||
return result
|
||||
result = self.parseHttpPathRemote(remaining)
|
||||
if result is not None:
|
||||
return result
|
||||
|
@ -898,6 +912,39 @@ class Application(applications.Application):
|
|||
finally:
|
||||
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):
|
||||
context.push()
|
||||
try:
|
||||
|
@ -1026,6 +1073,9 @@ class Application(applications.Application):
|
|||
'glasnost://%s' % dispatcherHostName)
|
||||
remaining = remaining[2:]
|
||||
|
||||
result = self.parseHttpPathHelp(remaining)
|
||||
if result is not None:
|
||||
return result
|
||||
result = self.parseHttpPathLanguage(remaining)
|
||||
if result is not None:
|
||||
return result
|
||||
|
|
|
@ -141,13 +141,14 @@ class DispatcherVirtualServer(VirtualServer):
|
|||
VirtualServer.init(self)
|
||||
self.applicationTokens = {}
|
||||
self.defaultAccessors = {}
|
||||
self.dispatcherIds = ['glasnost://system']
|
||||
self.dispatcherIds = ['glasnost://system', 'glasnost://help']
|
||||
self.serverAccessors = {}
|
||||
self.serverInfos = {}
|
||||
self.virtualServerIds = {}
|
||||
self.virtualServerIdProfiles = {
|
||||
'glasnost://help': ['basic', 'cms', 'translations'],
|
||||
'glasnost://system': ['basic', 'cms', 'translations'],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Dispatcher(Server):
|
||||
|
|
|
@ -370,7 +370,8 @@ class IdentitiesServer(commonIdentities.IdentitiesCommonMixin,
|
|||
|
||||
def rememberId(self, id):
|
||||
virtualServerId = context.getVar('applicationId')
|
||||
if virtualServerId == 'glasnost://system/identities':
|
||||
if virtualServerId in ['glasnost://help/identities',
|
||||
'glasnost://system/identities']:
|
||||
return
|
||||
virtualServer = self.getVirtualServer(virtualServerId)
|
||||
userId = self.getUserId()
|
||||
|
|
|
@ -109,7 +109,13 @@ class PageNamesServer(PageNamesCommonMixin, ObjectsServer):
|
|||
for objectId, object in virtualServer.objects.items():
|
||||
if object.name == name:
|
||||
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
|
||||
virtualServer = self.getVirtualServer(virtualServerId)
|
||||
for objectId, object in virtualServer.objects.items():
|
||||
|
@ -123,7 +129,13 @@ class PageNamesServer(PageNamesCommonMixin, ObjectsServer):
|
|||
for objectId, object in virtualServer.objects.items():
|
||||
if object.name == name:
|
||||
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
|
||||
virtualServer = self.getVirtualServer(virtualServerId)
|
||||
for objectId, object in virtualServer.objects.items():
|
||||
|
@ -137,7 +149,13 @@ class PageNamesServer(PageNamesCommonMixin, ObjectsServer):
|
|||
for objectId, object in virtualServer.objects.items():
|
||||
if object.mappedId == mappedId:
|
||||
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
|
||||
virtualServer = self.getVirtualServer(virtualServerId)
|
||||
for objectId, object in virtualServer.objects.items():
|
||||
|
|
|
@ -589,7 +589,7 @@ class TranslationsServer(TranslationsCommonMixin, AdministrableServerMixin,
|
|||
virtualServer.lock.release()
|
||||
virtualServer.markCoreAsDirty()
|
||||
elif not ignoreNew:
|
||||
if virtualServerId == 'glasnost://system':
|
||||
if virtualServerId in ['glasnost://help', 'glasnost://system']:
|
||||
return ('', '', 'ignored') # or use gettext ?
|
||||
|
||||
# Check that the string exists on the server before creating its
|
||||
|
|
|
@ -524,16 +524,12 @@ class rootUrl(httpUrl):
|
|||
dispatcherHostName = None
|
||||
dispatcherPort = None
|
||||
|
||||
if self.dispatcherHostName == 'system' or (
|
||||
if self.dispatcherHostName in ['help', 'system'] or (
|
||||
(self.dispatcherHostName is None
|
||||
or self.dispatcherHostName == dispatcherHostName)
|
||||
and (self.dispatcherPort is None
|
||||
or self.dispatcherPort == dispatcherPort)):
|
||||
if context.getVar('languageSetInUrl') and \
|
||||
not 'ignoreLanguage' in keywords.keys():
|
||||
return httpScriptDirectoryPath + \
|
||||
context.getVar('readLanguages')[0] + '/'
|
||||
return httpScriptDirectoryPath
|
||||
result = httpScriptDirectoryPath
|
||||
else:
|
||||
if self.dispatcherHostName is not None:
|
||||
dispatcherHostName = self.dispatcherHostName
|
||||
|
@ -549,10 +545,12 @@ class rootUrl(httpUrl):
|
|||
dispatcherHostName, dispatcherPort)
|
||||
result = '%sremote/%s/' % (
|
||||
httpScriptDirectoryPath, dispatcherHostNameAndPort)
|
||||
if context.getVar('languageSetInUrl') and \
|
||||
not 'ignoreLanguage' in keywords.keys():
|
||||
result += context.getVar('readLanguages')[0] + '/'
|
||||
return result
|
||||
if context.getVar('helpInUrl'):
|
||||
result = '%shelp/' % result
|
||||
if context.getVar('languageSetInUrl') \
|
||||
and not 'ignoreLanguage' in keywords.keys():
|
||||
result = '%s%s/' % (result, context.getVar('readLanguages')[0])
|
||||
return result
|
||||
|
||||
|
||||
class aliasUrl(rootUrl):
|
||||
|
|
|
@ -599,7 +599,7 @@ def getDispatcherAccessor(dispatcherId):
|
|||
dispatcherHostNameAndPort = extractApplicationHostNameAndPort(dispatcherId)
|
||||
dispatcherInfos = dispatcherHostNameAndPort.split(':', 1)
|
||||
dispatcherHostName = dispatcherInfos[0]
|
||||
if dispatcherHostName == 'system':
|
||||
if dispatcherHostName in ['help', 'system']:
|
||||
dispatcherHostName = context.getVar('dispatcherHostName')
|
||||
if len(dispatcherInfos) < 2:
|
||||
dispatcherPort = context.getVar('dispatcherPort')
|
||||
|
|
|
@ -1260,7 +1260,8 @@ class ObjectsProxy(ObjectsCommonMixin, AdministrableProxyMixin, Proxy):
|
|||
defaultDispatcherId = context.getVar('defaultDispatcherId')
|
||||
dispatcherId = context.getVar('dispatcherId')
|
||||
if not commonTools.extractDispatcherId(objectId) in [
|
||||
defaultDispatcherId, dispatcherId, 'glasnost://system']:
|
||||
defaultDispatcherId, dispatcherId, 'glasnost://help',
|
||||
'glasnost://system']:
|
||||
for id, label in labels.items():
|
||||
label += _(' (at <%s>)') \
|
||||
% extractApplicationHostNameAndPort(objectId)
|
||||
|
@ -1323,7 +1324,8 @@ class ObjectsProxy(ObjectsCommonMixin, AdministrableProxyMixin, Proxy):
|
|||
defaultDispatcherId = context.getVar('defaultDispatcherId')
|
||||
dispatcherId = context.getVar('dispatcherId')
|
||||
if not commonTools.extractDispatcherId(objectId) in [
|
||||
defaultDispatcherId, dispatcherId, 'glasnost://system']:
|
||||
defaultDispatcherId, dispatcherId, 'glasnost://help',
|
||||
'glasnost://system']:
|
||||
labelTranslated += _(' (at <%s>)') \
|
||||
% extractApplicationHostNameAndPort(objectId)
|
||||
return labelTranslated
|
||||
|
|
|
@ -1050,8 +1050,6 @@ class Server(things.BaseThing, applications.Application):
|
|||
virtualServer.markAllAsDirtyFIXME()
|
||||
virtualServer.savePendingRequests()
|
||||
return 0
|
||||
if doSystem:
|
||||
destinationDispatcherId = 'glasnost://system'
|
||||
if sourceDispatcherId and destinationDispatcherId:
|
||||
# Convert all the ids from sourceDispatcherId to
|
||||
# destinationDispatcherId.
|
||||
|
@ -1627,7 +1625,7 @@ class AdministrableServerMixin:
|
|||
|
||||
virtualServerId = context.getVar('applicationId')
|
||||
dispatcherId = commonTools.extractDispatcherId(virtualServerId)
|
||||
if dispatcherId == 'glasnost://system':
|
||||
if dispatcherId in ['glasnost://help', 'glasnost://system']:
|
||||
return 0
|
||||
virtualServer = self.getVirtualServer(virtualServerId)
|
||||
admin = virtualServer.admin
|
||||
|
|
Reference in New Issue