Loading ...
Sorry, an error occurred while loading the content.

Re: [Cheetahtemplate-discuss] Site Builder Design

Expand Messages
  • Stephan Diehl
    ... I m not entirely sure if this will help you, but I wanted to write up a recipe for the wiki anyway... Problem: Have a website with different skins
    Message 1 of 4 , Nov 1, 2002
    • 0 Attachment
      On Friday 01 November 2002 04:41, you wrote:
      > This is a long and complex set of questions. (Actually, I'm just asking you
      > to provide me a complete design, but I'll take what I can get! ;-) I am
      > trying to build a 'site builder' right now. I would like to only maintain
      > once set of templates for the entire system -- all domains. (All users have
      > access to a subset of the available templates, and many customers will use
      > the same template more than once for more than one page.) User's don't get
      > to create templates, only provide their own data to fill them with. I'm
      > trying to figure out the best way to do this. My current thinking is to
      > store their data in XML in their home directory, or perhaps in MySQL, and
      > then have a servlet that calls the appropriate template and passes the data
      > as an argument. Seems kind of clunky. Here's the layout I'm thinking right
      > now. (Running out of WebKit.)
      >
      > (long winding description snipped)

      I'm not entirely sure if this will help you, but I wanted to write up a
      recipe for the wiki anyway...

      Problem:
      Have a website with different skins (depending on domain, user, etc.)

      Solution:
      This is a variant of the containment approach.
      You have to create the following directory structure (and place it somewhere
      in the Python Path):
      ServerTemplates
      |
      |-- __init__.py
      |-- TemplateFactory.py
      |-- Generic
      |--Domain1
      |--Domain2
      |--DomainN

      TemplateFactory looks like this:

      ------------------------------------------------------------------------------------------------------
      import os,sys

      class TemplateStore:
      def __init__(self,site = 'Generic'):
      self.template = {}
      self._site = site
      if not
      os.path.isdir(os.path.join('/usr/local/Intranet/ServerTemplate',site)):
      raise "Template directory %s is not available" % site

      def site(self):
      return self._site

      def getTemplate(self,tempName,searchList=[]):
      if self.template.has_key(tempName):
      template = self.template[tempName]
      else:
      modname = 'ServerTemplate.'+self.site()+'.'+tempName
      try:
      __import__(modname)
      except ImportError:
      raise ImportError('no module named %s' % modname)
      template = getattr(sys.modules[modname],tempName)()
      self.template[tempName] = template

      tsearch = template.searchList()
      #print 'searchList: ',searchList
      for item in searchList:
      if item not in tsearch:
      template.addToSearchList(item)

      return template
      --------------------------------------------------------------------------------------------------------

      In your Site servlet (maybe SidebarPage or something similar) you have
      the following additional methods:

      def initTmplStore(self):
      tmplStore = {}
      for server in siteList: #siteList contains a list of your sites
      if not tmplStore.has_key(server):
      tmplStore[server] = TemplateStore(server)

      #print tmplStore
      return tmplStore

      def getTemplate(self,name,searchList=[]):
      return self._templates[self.getSite()].getTemplate(name,searchList)

      def getSite(self):
      # get your site
      # by whatever means that is necessary
      return site


      Now, any servlet that inherits from your base site, just calls
      getTemplate("myTemplateName")
      and automatically gets the right template

      This can only work of course, if all "DomainN" directories contain the same
      named (Cheetah) Templates.

      Hope that helps

      Stephan


      -------------------------------------------------------
      This sf.net email is sponsored by: See the NEW Palm
      Tungsten T handheld. Power & Color in a compact size!
      http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • jamie@labarts.com
      This is pretty cool and I think basically what I was looking for. Where does the site data come from? ... This sf.net email is sponsored by: See the NEW Palm
      Message 2 of 4 , Nov 1, 2002
      • 0 Attachment
        This is pretty cool and I think basically what I was looking for. Where does
        the site data come from?

        On Friday 01 November 2002 03:11 am, Stephan Diehl wrote:
        > On Friday 01 November 2002 04:41, you wrote:
        > > This is a long and complex set of questions. (Actually, I'm just asking
        > > you to provide me a complete design, but I'll take what I can get! ;-) I
        > > am trying to build a 'site builder' right now. I would like to only
        > > maintain once set of templates for the entire system -- all domains. (All
        > > users have access to a subset of the available templates, and many
        > > customers will use the same template more than once for more than one
        > > page.) User's don't get to create templates, only provide their own data
        > > to fill them with. I'm trying to figure out the best way to do this. My
        > > current thinking is to store their data in XML in their home directory,
        > > or perhaps in MySQL, and then have a servlet that calls the appropriate
        > > template and passes the data as an argument. Seems kind of clunky. Here's
        > > the layout I'm thinking right now. (Running out of WebKit.)
        > >
        > > (long winding description snipped)
        >
        > I'm not entirely sure if this will help you, but I wanted to write up a
        > recipe for the wiki anyway...
        >
        > Problem:
        > Have a website with different skins (depending on domain, user, etc.)
        >
        > Solution:
        > This is a variant of the containment approach.
        > You have to create the following directory structure (and place it
        > somewhere in the Python Path):
        > ServerTemplates
        >
        > |-- __init__.py
        > |-- TemplateFactory.py
        > |-- Generic
        > |--Domain1
        > |--Domain2
        > |--DomainN
        >
        > TemplateFactory looks like this:
        >
        > ---------------------------------------------------------------------------
        >--------------------------- import os,sys
        >
        > class TemplateStore:
        > def __init__(self,site = 'Generic'):
        > self.template = {}
        > self._site = site
        > if not
        > os.path.isdir(os.path.join('/usr/local/Intranet/ServerTemplate',site)):
        > raise "Template directory %s is not available" % site
        >
        > def site(self):
        > return self._site
        >
        > def getTemplate(self,tempName,searchList=[]):
        > if self.template.has_key(tempName):
        > template = self.template[tempName]
        > else:
        > modname = 'ServerTemplate.'+self.site()+'.'+tempName
        > try:
        > __import__(modname)
        > except ImportError:
        > raise ImportError('no module named %s' % modname)
        > template = getattr(sys.modules[modname],tempName)()
        > self.template[tempName] = template
        >
        > tsearch = template.searchList()
        > #print 'searchList: ',searchList
        > for item in searchList:
        > if item not in tsearch:
        > template.addToSearchList(item)
        >
        > return template
        > ---------------------------------------------------------------------------
        >-----------------------------
        >
        > In your Site servlet (maybe SidebarPage or something similar) you have
        > the following additional methods:
        >
        > def initTmplStore(self):
        > tmplStore = {}
        > for server in siteList: #siteList contains a list of your sites
        > if not tmplStore.has_key(server):
        > tmplStore[server] = TemplateStore(server)
        >
        > #print tmplStore
        > return tmplStore
        >
        > def getTemplate(self,name,searchList=[]):
        > return self._templates[self.getSite()].getTemplate(name,searchList)
        >
        > def getSite(self):
        > # get your site
        > # by whatever means that is necessary
        > return site
        >
        >
        > Now, any servlet that inherits from your base site, just calls
        > getTemplate("myTemplateName")
        > and automatically gets the right template
        >
        > This can only work of course, if all "DomainN" directories contain the same
        > named (Cheetah) Templates.
        >
        > Hope that helps
        >
        > Stephan



        -------------------------------------------------------
        This sf.net email is sponsored by: See the NEW Palm
        Tungsten T handheld. Power & Color in a compact size!
        http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Stephan Diehl
        ... I get the information I need from (within a servlet): self.request().environ()[ SERVER_ADDR ] ... This sf.net email is sponsored by: See the NEW Palm
        Message 3 of 4 , Nov 2, 2002
        • 0 Attachment
          On Friday 01 November 2002 17:41, you wrote:
          > This is pretty cool and I think basically what I was looking for. Where
          > does the site data come from?

          I get the information I need from (within a servlet):

          self.request().environ()['SERVER_ADDR']


          >
          > On Friday 01 November 2002 03:11 am, Stephan Diehl wrote:
          > > On Friday 01 November 2002 04:41, you wrote:
          > > > This is a long and complex set of questions. (Actually, I'm just asking
          > > > you to provide me a complete design, but I'll take what I can get! ;-)
          > > > ...


          -------------------------------------------------------
          This sf.net email is sponsored by: See the NEW Palm
          Tungsten T handheld. Power & Color in a compact size!
          http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        Your message has been successfully submitted and would be delivered to recipients shortly.