diff --git a/Makefile b/Makefile index ca5a4f1b..37a0bf1e 100644 --- a/Makefile +++ b/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 diff --git a/glasnost-ctl.py b/glasnost-ctl.py index 1f6e4ace..686067e2 100755 --- a/glasnost-ctl.py +++ b/glasnost-ctl.py @@ -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': diff --git a/glasnost-web/code/webhandler.py b/glasnost-web/code/webhandler.py index 04c0ae0f..f9e14264 100644 --- a/glasnost-web/code/webhandler.py +++ b/glasnost-web/code/webhandler.py @@ -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 diff --git a/servers/Dispatcher/Dispatcher.py b/servers/Dispatcher/Dispatcher.py index f70a2504..55c6cb2b 100755 --- a/servers/Dispatcher/Dispatcher.py +++ b/servers/Dispatcher/Dispatcher.py @@ -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): diff --git a/servers/IdentitiesServer/IdentitiesServer.py b/servers/IdentitiesServer/IdentitiesServer.py index d76bd23a..30287daf 100755 --- a/servers/IdentitiesServer/IdentitiesServer.py +++ b/servers/IdentitiesServer/IdentitiesServer.py @@ -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() diff --git a/servers/PageNamesServer/PageNamesServer.py b/servers/PageNamesServer/PageNamesServer.py index 2d1e5c88..5ced4a76 100755 --- a/servers/PageNamesServer/PageNamesServer.py +++ b/servers/PageNamesServer/PageNamesServer.py @@ -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(): diff --git a/servers/TranslationsServer/TranslationsServer.py b/servers/TranslationsServer/TranslationsServer.py index 19519d98..48442685 100755 --- a/servers/TranslationsServer/TranslationsServer.py +++ b/servers/TranslationsServer/TranslationsServer.py @@ -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 diff --git a/shared/common/xhtmlgenerator.py b/shared/common/xhtmlgenerator.py index 76560ea5..f4f86675 100644 --- a/shared/common/xhtmlgenerator.py +++ b/shared/common/xhtmlgenerator.py @@ -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): diff --git a/shared/proxy/DispatcherProxy.py b/shared/proxy/DispatcherProxy.py index 915f8749..8ea158a5 100644 --- a/shared/proxy/DispatcherProxy.py +++ b/shared/proxy/DispatcherProxy.py @@ -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') diff --git a/shared/proxy/ObjectsProxy.py b/shared/proxy/ObjectsProxy.py index ceed32d5..aee19664 100644 --- a/shared/proxy/ObjectsProxy.py +++ b/shared/proxy/ObjectsProxy.py @@ -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 diff --git a/shared/server/ObjectsServer.py b/shared/server/ObjectsServer.py index a8bb5108..db97561e 100644 --- a/shared/server/ObjectsServer.py +++ b/shared/server/ObjectsServer.py @@ -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