Internal Django method, used to return the placeholder ID when exporting the model instance.
332135
def value_from_object(self, obj):
        
        try:
            # not using self.attname, access the descriptor instead.
            placeholder = getattr(obj, self.name)
        except Placeholder.DoesNotExist:
            return None   # Still allow ModelForm / admin to open and create a new Placeholder if the table was truncated.

        return placeholder.id if placeholder else None
359411
def verify(self, cls, id_field, id_val, obj_from_cache):
        
        return getattr(obj_from_cache, id_field) == id_val
1216218
def get_or_create_placeholder(self, page, placeholder_slot):
        
        placeholder, created = get_or_create_placeholder(
            page, placeholder_slot, delete_existing=self.delete_first)
        return placeholder, created
159414
function placeholder (model, name, spec) {
    // if colum is id then needs to be wrapped in UNHEX
    if (spec.type === 'id' && model.binaryIds) {
        return `UNHEX(:${name})`
    }
    // if column is data and compression is in use it is hex
    else if (spec.type === 'data' && model.compression) {
        return `FROM_BASE64(:${name})`
    }
    else {
        return `:${name}`
    }
}
1100100
def get_name(model_id):
    
    name = _names.get(model_id)
    if name is None:
        name = 'id = %s (no name)' % str(model_id)
    return name
1027037
def get_frontend_data_dict_for_placeholders(placeholders, request, editable=False):
    
    data_dict = {}
    for placeholder in placeholders:
        if placeholder:
            plugins = []

            # We don't use the helper method `placeholder.get_plugins()` because of the wrong order by path.
            placeholder_plugins = placeholder.cmsplugin_set.filter(language=request.LANGUAGE_CODE).order_by(
                settings.DJANGOCMS_SPA_PLUGIN_ORDER_FIELD)

            for plugin in placeholder_plugins:
                # We need the complete cascading structure of the plugins in the frontend. This is why we ignore the
                # children here and add them later in the loop.
                if not plugin.parent:
                    plugins.append(get_frontend_data_dict_for_plugin(
                        request=request,
                        plugin=plugin,
                        editable=editable)
                    )

            if plugins or editable:
                data_dict[placeholder.slot] = {
                    'type': 'cmp-%s' % placeholder.slot,
                    'plugins': plugins,
                }

            if editable:
                # This is the structure of the template `cms/toolbar/placeholder.html` that is used to register
                # the frontend editing.
                from cms.plugin_pool import plugin_pool
                plugin_types = [cls.__name__ for cls in plugin_pool.get_all_plugins(placeholder.slot, placeholder.page)]
                allowed_plugins = plugin_types + plugin_pool.get_system_plugins()

                data_dict[placeholder.slot]['cms'] = [
                    'cms-placeholder-{}'.format(placeholder.pk),
                    {
                        'type': 'placeholder',
                        'name': str(placeholder.get_label()),
                        'page_language': request.LANGUAGE_CODE,
                        'placeholder_id': placeholder.pk,
                        'plugin_language': request.LANGUAGE_CODE,
                        'plugin_restriction': [module for module in allowed_plugins],
                        'addPluginHelpTitle': 'Add plugin to placeholder {}'.format(placeholder.get_label()),
                        'urls': {
                            'add_plugin': placeholder.get_add_url(),
                            'copy_plugin': placeholder.get_copy_url()
                        }
                    }
                ]

    return data_dict
723576
def find_by_id(self, organization_export, params={}, **options): 
        
        path = "/organization_exports/%s" % (organization_export)
        return self.client.get(path, params, **options)
945260
def get_object(table, id=None, condition=None, cache=False, fields=None, use_local=False,
               engine_name=None, session=None):
    
    from uliweb import functions, settings
    
    model = get_model(table, engine_name)
        
    #if id is an object of Model, so get the real id value
    if isinstance(id, Model):
        return id
      
    if cache:
        if use_local:
            s = get_session(session)
            key = get_object_id(s.engine_name, model.tablename, id)
            value = s.get_local_cache(key)
            if value:
                return value
        obj = model.get(id, condition=condition, fields=fields, cache=True)
        if use_local:
            value = s.get_local_cache(key, obj)
    else:
        obj = model.get(id, condition=condition, fields=fields)
    
    return obj
1290541
def id(self):
        
        if self._id is None:
            self._id = int(self._element.get('id'))
        return self._id
1051900
def _printable_id_code(self):
        
        code = str(self.id_code)
        while len(code) < self._code_size:
            code = '0' + code

        return code
902100
def get_placeholder_data(self, request, obj=None):
        
        # Return all placeholder fields in the model.
        if not hasattr(self.model, '_meta_placeholder_fields'):
            return []

        data = []
        for name, field in self.model._meta_placeholder_fields.items():
            assert isinstance(field, PlaceholderField)
            data.append(PlaceholderData(
                slot=field.slot,
                title=field.verbose_name.capitalize(),
                fallback_language=None,  # Information cant' be known by "render_placeholder" in the template.
            ))

        return data
1042413
def get_data(model, instance_id, kind=''):
    
    instance = get_instance(model, instance_id)

    if not instance:
        return

    return ins2dict(instance, kind)
143303
def type_id(self):
        
        try:
            return ContentType.objects.get_for_model(self.model, for_concrete_model=False).id
        except DatabaseError as e:
            raise DatabaseError("Unable to fetch ContentType object, is a plugin being registered before the initial syncdb? (original error: {0})".format(str(e)))
154708
def to_id(self):
        
        return "%s%s%s%s%s" % (TraceId.VERSION, TraceId.DELIMITER,
                               format(self.start_time, 'x'),
                               TraceId.DELIMITER, self.__number)
1150054
def get_for_model(self, model):
        
        return self.get_or_create(
            content_type    = ContentType.objects.get_for_model(model),
            object_id       = model.pk
        )
1090276
def str_id(self):
        ""
        id_or_name = self.id_or_name
        if id_or_name is not None and isinstance(id_or_name, str):
            return id_or_name
        return None
1194068
def create_placeholder_access_object(self, instance):
        
        related_model = self.related_model

        def get_related_model_objects(name):
            """
            Obtains the related model objects based upon the slot name.

            :param name: The slot name in string form.
            :returns; Related model contents if they exist or it will
            raise a `DoesNotExist` exception.
            """
            # Parent type, parent id and slot are set to be unique on the default
            # related model and therefore treated as such here.
            return related_model.objects.get(
                parent_type=ContentType.objects.get_for_model(type(instance)),
                parent_id=instance.id,
                slot=name,
            ).get_content_items()

        class PlaceholderAccess(object):
            def __getattribute__(self, name):
                """
                Allow placeholder contents to be accessed via slot
                name on the descriptor object.

                For example if the slot was named `main` and you had
                a descriptor named `slots` on an object named `page`
                you would call it by `page.slots.main`.

                If a slot name is used that does not exist an
                `AttributeError` will be raised.

                If you get this error for a slot that should exist, you may
                need to run `manage.py add_missing_placeholders`.
                """
                try:
                    return get_related_model_objects(name)
                except related_model.DoesNotExist:
                    return super(PlaceholderAccess, self).__getattribute__(name)

            def __getitem__(self, item):
                """
                Allow placeholder contents to be accessed via slot
                name one the descriptor object via a dictionary
                lookup.

                For example if the slot was named `main` and you had
                a descriptor named `slots` on an object named `page`
                you would call it by `page.slots['main']`.

                If a slot name is used that does not exist a
                `KeyError` will be raised.
                """
                try:
                    return get_related_model_objects(item)
                except related_model.DoesNotExist:
                    raise KeyError

        return PlaceholderAccess()