Returns the single holding container object of this content type

    :param portal_type: The portal type requested
    :type portal_type: string
    :returns: Folderish container where the portal type can be created
    :rtype: AT content object
761865
def get_container_for(portal_type):
    
    container_paths = config.CONTAINER_PATHS_FOR_PORTAL_TYPES
    container_path = container_paths.get(portal_type)

    if container_path is None:
        return None

    portal_path = get_path(get_portal())
    return get_object_by_path("/".join([portal_path, container_path]))
734549
def portalId(self):
        """"""
        if self._portalId is None:
            self._portalId = self._findPortalId()
        return self._portalId
733128
async def container(self, container=None, container_type=None, params=None):
        
        # Container versioning is a bit tricky, primitive type containers are not versioned.
        elem_type = x.container_elem_type(container_type, params)
        raw_container = container_is_raw(container_type, params)
        elem_elementary = TypeWrapper.is_elementary_type(elem_type)
        is_versioned = not elem_elementary and not raw_container
        version = None

        if is_versioned:
            version = await self.version(container_type, params, elem=container)
            if self.is_tracked():
                return self.get_tracked()

        if hasattr(container_type, 'boost_serialize'):
            container = container_type() if container is None else container
            self.pop_track(is_versioned)
            return await container.boost_serialize(self, elem=container, elem_type=container_type, params=params, version=version)

        # Container entry version + container
        if self.writing:
            self.pop_track(is_versioned)
            return await self.container_dump(container, container_type, params)
        else:
            obj = await self.container_load(container_type, params=params, container=container)
            return self.track_obj(obj, is_versioned)
310721
def get_container_or_none(self, type_):
        

        type_ = type_traits.remove_alias(type_)
        type_ = type_traits.remove_cv(type_)

        utils.loggers.queries_engine.debug(
            "Container traits: cleaned up search %s", type_)

        if isinstance(type_, cpptypes.declarated_t):
            cls_declaration = type_traits.remove_alias(type_.declaration)
        elif isinstance(type_, class_declaration.class_t):
            cls_declaration = type_
        elif isinstance(type_, class_declaration.class_declaration_t):
            cls_declaration = type_
        else:
            utils.loggers.queries_engine.debug(
                "Container traits: returning None, type not known\n")
            return

        if not cls_declaration.name.startswith(self.name() + '<'):
            utils.loggers.queries_engine.debug(
                "Container traits: returning None, " +
                "declaration starts with " + self.name() + '<\n')
            return

        # When using libstd++, some container traits are defined in
        # std::tr1::. See remove_template_defaults_tester.py.
        # In this case the is_defined_in_xxx test needs to be done
        # on the parent
        decl = cls_declaration
        if isinstance(type_, class_declaration.class_declaration_t):
            is_ns = isinstance(type_.parent, namespace.namespace_t)
            if is_ns and type_.parent.name == "tr1":
                decl = cls_declaration.parent
        elif isinstance(type_, cpptypes.declarated_t):
            is_ns = isinstance(type_.declaration.parent, namespace.namespace_t)
            if is_ns and type_.declaration.parent.name == "tr1":
                decl = cls_declaration.parent

        for ns in std_namespaces:
            if traits_impl_details.impl_details.is_defined_in_xxx(ns, decl):
                utils.loggers.queries_engine.debug(
                    "Container traits: get_container_or_none() will return " +
                    cls_declaration.name)
                # The is_defined_in_xxx check is done on decl, but we return
                # the original declation so that the rest of the algorithm
                # is able to work with it.
                return cls_declaration

        # This should not happen
        utils.loggers.queries_engine.debug(
            "Container traits: get_container_or_none() will return None\n")
88054
def get_parent_objects(self, context):
        
        parent_object = api.get_parent(context)
        portal_type = api.get_portal_type(context)
        return parent_object.objectValues(portal_type)
847199
def getPrefixFor(self, portal_type):
        
        prefix = [p for p in self.getIDFormatting() if p['portal_type'] == portal_type]
        if prefix:
            return prefix[0]['prefix']
        else:
            return portal_type
500940
def choose_type(cls, content_type):
        """"""
        return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
            else cls.type_cls.FILE
913970
def get_roles_by_type(self, role_type, view = None):
    
    return roles.get_roles_by_type(self._get_resource_root(), self.name,
        role_type, self._get_cluster_name(), view)
413120
def portalAdmin(self):
        """"""
        from ..manageportal import PortalAdministration
        return PortalAdministration(admin_url="https://%s/portaladmin" % self.portalHostname,
                                    securityHandler=self._securityHandler,
                                    proxy_url=self._proxy_url,
                                    proxy_port=self._proxy_port,
                                    initalize=False)
1121906
def generate_id(self, portal_type, batch_size = None):
        
        plone = getSite()
        portal_id = plone.getId()

        if portal_type == 'News Item':
            portal_type = 'NewsItem'

        idserver_url = os.environ.get('IDServerURL')
        try:
            if batch_size:
                # GET
                f = urllib.urlopen('%s/%s%s?%s' % (
                        idserver_url,
                        portal_id,
                        portal_type,
                        urllib.urlencode({'batch_size': batch_size}))
                        )
            else:
                f = urllib.urlopen('%s/%s%s' % (
                    idserver_url, portal_id, portal_type
                    )
                )
            id = f.read()
            f.close()
        except:
            from sys import exc_info
            info = exc_info()
            import zLOG; zLOG.LOG('INFO', 0, '', 'generate_id raised exception: %s, %s \n idserver_url: %s' % (info[0], info[1], idserver_url))
            raise IDServerUnavailable(_('ID Server unavailable'))
        return id
1246867
def attach_storage(self, server, storage, storage_type, address):
        
        body = {'storage_device': {}}
        if storage:
            body['storage_device']['storage'] = str(storage)

        if storage_type:
            body['storage_device']['type'] = storage_type

        if address:
            body['storage_device']['address'] = address

        url = '/server/{0}/storage/attach'.format(server)
        res = self.post_request(url, body)
        return Storage._create_storage_objs(res['server']['storage_devices'], cloud_manager=self)
394925
def get_object(self, catalog, portal_type, title=None, **kwargs):
        
        if not title and not kwargs:
            return None
        contentFilter = {"portal_type": portal_type}
        if title:
            contentFilter['title'] = to_unicode(title)
        contentFilter.update(kwargs)
        brains = catalog(contentFilter)
        if len(brains) > 1:
            logger.info("More than one object found for %s" % contentFilter)
            return None
        elif len(brains) == 0:
            if portal_type == 'AnalysisService':
                brains = catalog(portal_type=portal_type, getKeyword=title)
                if brains:
                    return brains[0].getObject()
            logger.info("No objects found for %s" % contentFilter)
            return None
        else:
            return brains[0].getObject()
524454
async def container_load(self, container_type, params=None, container=None, obj=None):
        
        if isinstance(obj, IModel):
            obj = obj.val

        if obj is None:
            return NoSetSentinel()

        c_len = len(obj)
        elem_type = params[0] if params else None
        if elem_type is None:
            elem_type = container_type.ELEM_TYPE

        res = container if container else []
        for i in range(c_len):
            try:
                self.tracker.push_index(i)
                fvalue = await self._load_field(elem_type,
                                                params[1:] if params else None,
                                                x.eref(res, i) if container else None, obj=obj[i])
                self.tracker.pop()

            except Exception as e:
                raise helpers.ArchiveException(e, tracker=self.tracker) from e

            if not container and not isinstance(fvalue, NoSetSentinel):
                res.append(fvalue)

        return res
517926
def get_search_results(portal_type=None, uid=None, **kw):
    

    # If we have an UID, return the object immediately
    if uid is not None:
        logger.info("UID '%s' found, returning the object immediately" % uid)
        return u.to_list(get_object_by_uid(uid))

    # allow to search search for the Plone Site with portal_type
    include_portal = False
    if u.to_string(portal_type) == "Plone Site":
        include_portal = True

    # The request may contain a list of portal_types, e.g.
    # `?portal_type=Document&portal_type=Plone Site`
    if "Plone Site" in u.to_list(req.get("portal_type")):
        include_portal = True

    # Build and execute a catalog query
    results = search(portal_type=portal_type, uid=uid, **kw)

    if include_portal:
        results = list(results) + u.to_list(get_portal())

    return results
963054
def content_type(self):
        
        value = 0
        for option in self.options:
            if option.number == defines.OptionRegistry.CONTENT_TYPE.number:
                value = int(option.value)
        return value
24693
def portal(self, portalID=None):
        """"""
        if portalID is None:
            portalID = self.portalSelf.id
        url = "%s/%s" % (self.root, portalID)
        return Portal(url=url,
                  securityHandler=self._securityHandler,
                  proxy_url=self._proxy_url,
                  proxy_port=self._proxy_port,
                  initalize=True)
602145
def make_storage_key(portal_type, prefix=None):
    
    key = portal_type.lower()
    if prefix:
        key = "{}-{}".format(key, prefix)
    return key