Changeset 573

Show
Ignore:
Timestamp:
10/04/07 19:39:31 (1 year ago)
Author:
ian
Message:

Site mapper/manager now supports concept of a 'default' site. Also renamed 'domain_globs' site config key to 'domains'

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pagoda/trunk/Pagoda/pagoda/command.py

    r572 r573  
    7070                "Enter site dburi [ex. sqlite:///devdata.sqlite]: " 
    7171            ) 
    72         while not site.get('domain_globs', ''): 
    73             site['domain_globs'] = raw_input( 
     72        while not site.get('domains', ''): 
     73            site['domains'] = raw_input( 
    7474                "Enter domain globs [ex. *.mysite.com, www.myothersite.*]: " 
    7575            ) 
     
    9393        create_site( 
    9494            site['name'],  
    95             site['dburi'],  
    96             site['domain_globs'],  
    97             site['use_app_resources'] 
     95            dburi=site['dburi'],  
     96            domains=site['domains'],  
     97            use_app_resources=site['use_app_resources'] 
    9898        ) 
    99         print "Success: Site %r created." % site_name 
     99        print "Success: Site %r created." % site['name'] 
    100100 
    101101    def site_remove(self, *args): 
  • pagoda/trunk/Pagoda/pagoda/site/manager.py

    r572 r573  
    9393    # Raise NameError if site_name is not in config 
    9494    if not is_site(site_name): 
    95         raise NameError("Error removing site %r: "   
    96             "Site does not exist in configuration!") 
     95        raise NameError( 
     96            "Error removing site %r: "   
     97            "Site does not exist in configuration!" % site_name 
     98        ) 
    9799 
    98100    # Remove site-specific resource directories 
     
    123125    return sites.keys() 
    124126 
    125 def create_site(site_name, dburi, domain_globs, use_app_resources=False): 
     127def create_site(site_name, dburi='', domains='', use_app_resources=False): 
    126128    """Create a new PagodaCMS site using the supplied parameters.""" 
    127129 
     
    131133        sites[site_name] = dict() 
    132134    sites[site_name]['dburi'] = dburi 
    133     sites[site_name]['domain_globs'] = domain_glob
     135    sites[site_name]['domains'] = domain
    134136 
    135137    # Create site directory, if not using existing app resources 
  • pagoda/trunk/Pagoda/pagoda/site/mapper.py

    r572 r573  
    1818 
    1919__all__ = ['PagodaSiteFilter', 'SITE_DOMAINS', 'update_domain_map', 
    20            'get_site_name'
     20           'get_site_name', 'DEFAULT_SITE_NAME'
    2121 
    2222SITE_DOMAINS = {} 
     23DEFAULT_SITE_NAME = 'default' 
    2324 
    2425def update_domain_map(domain_map=SITE_DOMAINS): 
     
    6970            if glob.fnmatch.fnmatch(url_domain, site_domain): 
    7071                return site_name 
     72    # If no domain glob matched, return default site (if there is one) 
     73    if domain_map.has_key(DEFAULT_SITE_NAME): 
     74        return DEFAULT_SITE_NAME 
    7175 
    7276class PagodaSiteFilter(cherrypy.filters.basefilter.BaseFilter): 
     
    8488        if site_name: 
    8589            request.headers[self.PAGODA_SITE_HEADER] = site_name 
     90        else: 
     91            raise cherrypy.HTTPError( 
     92                status=500,  
     93                message="Site not found!" 
     94            ) 

Log in as guest/pagoda to create tickets