How to use the orchestra.contrib.websites.utils.normurlpath function in orchestra

To help you get started, we’ve selected a few orchestra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glic3rinu / django-orchestra / orchestra / contrib / websites / backends / apache.py View on Github external
def get_proxies(self, directives):
        proxies = []
        for proxy in directives.get('proxy', []):
            proxy = proxy.split()
            location = proxy[0]
            target = proxy[1]
            options = ' '.join(proxy[2:])
            location = normurlpath(location)
            proxy = textwrap.dedent("""\
                ProxyPass {location}/ {target} {options}
                ProxyPassReverse {location}/ {target}""".format(
                    location=location, target=target, options=options)
            )
            proxies.append(
                (location, proxy)
            )
        return proxies
github glic3rinu / django-orchestra / orchestra / contrib / websites / backends / apache.py View on Github external
def get_proxies(self, directives):
        proxies = []
        for proxy in directives.get('proxy', []):
            proxy = proxy.split()
            location = proxy[0]
            target = proxy[1]
            options = ' '.join(proxy[2:])
            location = normurlpath(location)
            proxy = textwrap.dedent("""\
                ProxyPass {location}/ {target} {options}
                ProxyPassReverse {location}/ {target}""".format(
                    location=location, target=target, options=options)
            )
            proxies.append(
                (location, proxy)
            )
        return proxies
github glic3rinu / django-orchestra / orchestra / contrib / websites / directives.py View on Github external
def validate_uniqueness(self, directive, values, locations):
        """ Validates uniqueness location, name and value """
        errors = defaultdict(list)
        value = directive.get('value', None)
        # location uniqueness
        location = None
        if self.is_location and value is not None:
            if not value and self.is_location:
                value = '/'
            location = normurlpath(value.split()[0])
        if location is not None and location in locations:
            errors['value'].append(ValidationError(
                "Location '%s' already in use by other content/directive." % location
            ))
        else:
            locations.add(location)
        
        # name uniqueness
        if self.unique_name and self.name in values:
            errors[None].append(ValidationError(
                _("Only one %s can be defined.") % self.get_verbose_name()
            ))
        
        # value uniqueness
        if value is not None:
            if self.unique_value and value in values.get(self.name, []):
github glic3rinu / django-orchestra / orchestra / contrib / websites / backends / apache.py View on Github external
def set_content_context(self, content, context):
        content_context = {
            'type': content.webapp.type,
            'location': normurlpath(content.path),
            'app_name': content.webapp.name,
            'app_path': content.webapp.get_path(),
        }
        context.update(content_context)
github glic3rinu / django-orchestra / orchestra / contrib / websites / backends / apache.py View on Github external
def set_content_context(self, content, context):
        content_context = {
            'type': content.webapp.type,
            'location': normurlpath(content.path),
            'app_name': content.webapp.name,
            'app_path': content.webapp.get_path(),
        }
        context.update(content_context)
github glic3rinu / django-orchestra / orchestra / contrib / websites / backends / apache.py View on Github external
def get_saas(self, directives):
        saas = []
        for name, values in directives.items():
            if name.endswith('-saas'):
                for value in values:
                    context = {
                        'location': normurlpath(value),
                    }
                    directive = settings.WEBSITES_SAAS_DIRECTIVES[name]
                    saas += self.get_directives(directive, context)
        return saas