def get_or_create(cls, dname):
        """
        Get the requested domain, or create it if it doesn't exist already
        @param  dname:  Domain name
        @type   dname:  str
        @rtype: Domain
        """
        Domain = cls
        dname = dname.hostname if hasattr(dname, 'hostname') else dname
        extras = 'www.{dn}'.format(dn=dname) if dname not in ('localhost', ) and not \
            re.match('^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$', dname) else None
        # Fetch the domain entry if it already exists
        logging.getLogger('ipsv.sites.domain').debug('Checking if the domain %s has already been registered', dname)
        domain = Session.query(Domain).filter(Domain.name == dname).first()

        # Otherwise create it now
        if not domain:
            logging.getLogger('ipsv.sites.domain')\
                .debug('Domain name does not yet exist, creating a new database entry')
            domain = Domain(name=dname, extras=extras)
            Session.add(domain)
            Session.commit()

        return domain
def get_or_create ( cls , dname ) : Domain = cls dname = dname . hostname if hasattr ( dname , 'hostname' ) else dname extras = 'www.{dn}' . format ( dn = dname ) if dname not in ( 'localhost' , ) and not re . match ( '^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$' , dname ) else None logging . getLogger ( 'ipsv.sites.domain' ) . debug ( 'Checking if the domain %s has already been registered' , dname ) domain = Session . query ( Domain ) . filter ( Domain . name == dname ) . first ( ) if not domain : logging . getLogger ( 'ipsv.sites.domain' ) . debug ( 'Domain name does not yet exist, creating a new database entry' ) domain = Domain ( name = dname , extras = extras ) Session . add ( domain ) Session . commit ( ) return domain
Get the requested domain, or create it if it doesn't exist already
        @param  dname:  Domain name
        @type   dname:  str
        @rtype: Domain