Example #1
0
def new_org(type=ORG_DEFAULT, block=True, **kwargs):
    if type == ORG_DEFAULT:
        org = reserve_pooled(type=type, **kwargs)

        if not org:
            org = queue.reserve('queued_org', block=block, type=type, **kwargs)

            if org:
                logger.debug(
                    'Reserved queued org',
                    'organization',
                    org_id=org.id,
                )
        else:
            logger.debug(
                'Reserved pooled org',
                'organization',
                org_id=org.id,
            )

        if org:
            new_pooled()
            return org

        org = Organization(type=type, **kwargs)
        org.initialize()
        org.commit()

        logger.debug(
            'Org init',
            'organization',
            org_id=org.id,
        )

        return org
    else:
        org = Organization(type=type, **kwargs)
        org.queue_initialize(block=block)

        logger.debug(
            'Queue org init',
            'organization',
            org_id=org.id,
        )

        return org
Example #2
0
def new_org(type=ORG_DEFAULT, block=True, **kwargs):
    if type == ORG_DEFAULT:
        org = reserve_pooled(type=type, **kwargs)

        if not org:
            org = queue.reserve('queued_org', block=block, type=type, **kwargs)

        if org:
            new_pooled()
            return org

        org = Organization(type=type, **kwargs)
        org.initialize()
        org.commit()

        return org
    else:
        org = Organization(type=type, **kwargs)
        org.queue_initialize(block=block)

        return org
Example #3
0
def new_org(type=ORG_DEFAULT, block=True, **kwargs):
    if type == ORG_DEFAULT:
        org = reserve_pooled(type=type, **kwargs)

        if not org:
            org = queue.reserve("queued_org", block=block, type=type, **kwargs)

        if org:
            new_pooled()
            return org

        org = Organization(type=type, **kwargs)
        org.initialize()
        org.commit()

        return org
    else:
        org = Organization(type=type, **kwargs)
        org.queue_initialize(block=block)

        return org
Example #4
0
def new_org(type=ORG_DEFAULT, block=True, **kwargs):
    if type == ORG_DEFAULT:
        org = reserve_pooled(type=type, **kwargs)

        if not org:
            org = queue.reserve('queued_org', block=block, type=type,
                **kwargs)

            if org:
                logger.debug('Reserved queued org', 'organization',
                    org_id=org.id,
                )
        else:
            logger.debug('Reserved pooled org', 'organization',
                org_id=org.id,
            )

        if org:
            new_pooled()
            return org

        org = Organization(type=type, **kwargs)
        org.initialize()
        org.commit()

        logger.debug('Org init', 'organization',
            org_id=org.id,
        )

        return org
    else:
        org = Organization(type=type, **kwargs)
        org.queue_initialize(block=block)

        logger.debug('Queue org init', 'organization',
            org_id=org.id,
        )

        return org