Returns the latest :class:`Content <pages.models.Content>`
        slug object that match the given slug for the current site domain.

        :param slug: the wanted slug.
189605
def get_content_slug_by_slug(self, slug):
        
        content = self.filter(type='slug', body=slug)
        if settings.PAGE_USE_SITE_ID:
            content = content.filter(page__sites__id=global_settings.SITE_ID)
        try:
            content = content.latest('creation_date')
        except self.model.DoesNotExist:
            return None
        else:
            return content
354081
def get(url, last_modified=None):
    
    try:
        with closing(urllib2.urlopen(url)) as page:
            if last_modified is not None:
                last_mod = dateutil.parser.parse(dict(page.info())['last-modified'])
                if last_mod <= last_modified:
                    return ""
            return page.read()
    except urllib2.URLError:
        return ""
795089
def _lazy_urls(self):
        
        def url_patterns():
            return self._urls()[0]

        return LazyURLPattern(url_patterns), self.namespace, self.slug
703245
def get_data_id_by_slug(self, slug):
        
        resolwe_host = os.environ.get('RESOLWE_HOST_URL')
        url = urllib.parse.urljoin(resolwe_host, '/api/data?slug={}&fields=id'.format(slug))

        with urllib.request.urlopen(url, timeout=60) as f:
            data = json.loads(f.read().decode('utf-8'))

        if len(data) == 1:
            return data[0]['id']
        elif not data:
            raise ValueError('Data not found for slug {}'.format(slug))
        else:
            raise ValueError('More than one data object returned for slug {}'.format(slug))
907923
def recent(category=None, pages=1, sort=None, order=None):
	""""""
	s = Search()
	s.recent(category, pages, sort, order)
	return s
107376
def get_active(slug=DEFAULT_TERMS_SLUG):
        """"""

        active_terms = cache.get('tandc.active_terms_' + slug)
        if active_terms is None:
            try:
                active_terms = TermsAndConditions.objects.filter(
                    date_active__isnull=False,
                    date_active__lte=timezone.now(),
                    slug=slug).latest('date_active')
                cache.set('tandc.active_terms_' + slug, active_terms, TERMS_CACHE_SECONDS)
            except TermsAndConditions.DoesNotExist:  # pragma: nocover
                LOGGER.error("Requested Terms and Conditions that Have Not Been Created.")
                return None

        return active_terms
983320
def get_object_url(self):
        

        if self.kwargs.get(self.slug_url_kwarg, False) == \
                    unicode(getattr(self.object, self.slug_field, "")) \
                    and not self.force_add:
            url = self.request.build_absolute_uri()
        else:
            url = self.bundle.get_view_url('edit', self.request.user,
                                           {'object': self.object},
                                           self.kwargs)
        return url
904905
def previous_page_url(self):
        
        if 'meta' in self._payload and 'previous_page_url' in self._payload['meta']:
            return self._payload['meta']['previous_page_url']
        elif 'previous_page_uri' in self._payload and self._payload['previous_page_uri']:
            return self._version.domain.absolute_url(self._payload['previous_page_uri'])

        return None
403254
public function slug($slug = null)
    {
        if (null === $slug) {
            return $this->slug;
        }

        $this->slug = $slug;

        return $this;
    }
1181251
def _create_date_slug(self):
        """"""
        if not self.pk:
            # haven't saved this yet, so use today's date
            d = utc_now()
        elif self.published and self.published_on:
            # use the actual published on date
            d = self.published_on
        elif self.updated_on:
            # default to the last-updated date
            d = self.updated_on
        self.date_slug = u"{0}/{1}".format(d.strftime("%Y/%m/%d"), self.slug)
315884
public function retrieveActiveBySlug($slug)
    {
        $query = $this->createQueryBuilder('c')
            ->where('c.isActive = :isActive')
            ->andWhere('c.slug = :slug')
            ->orderBy('c.rank', 'ASC')
            ->setMaxResults(1)
            ->getQuery();

        $query->setParameter('isActive', true);
        $query->setParameter('slug', $slug);

        return $query->getOneOrNullResult();
    }
787573
def slug(self):
        
        return '{:s}@{:s}[{:d}, {:d}]'.format(self.type, self.seqid,
                                              self.start + 1, self.end)
52625
public static function getCurrentSlug()
    {
        // Defintions
        $slug = self::get('post_type', '');

        // Define current post type's contents
        if (empty($slug)) {
            // Get slug by post type
            $post = self::get('post', 0);

            if (!empty($post)) {
                return get_post_type($post);
            }

            global $pagenow;

            // Custom page slug
            if (in_array($pagenow, ['admin.php'])) {
                return 'admin';
            }

            // Post slug
            if (in_array($pagenow, ['edit.php', 'post-new.php', 'post.php', 'edit-tags.php'])) {
                return 'post';
            }

            // Comment slug
            if (in_array($pagenow, ['edit-comments.php', 'comment.php'])) {
                return 'comment';
            }

            // Media slug
            if (in_array($pagenow, ['upload.php', 'media-new.php'])) {
                return 'attachment';
            }

            // User slug
            if (in_array($pagenow, ['users.php', 'user-new.php', 'user-edit.php', 'profile.php'])) {
                return 'user';
            }

            // Appearance slug
            if ('nav-menus.php' == $pagenow) {
                return 'nav_menu_item';
            }
        }

        return $slug;
    }
1163924
def slug(self, language=None, fallback=True):
        

        slug = self.get_content(language, 'slug', language_fallback=fallback)
        if slug == '':
            return "Page {0}".format(self.pk)

        return slug
208738
public static function getBySlug($slug)
    {
        $slug_parts = explode("-", $slug, 2);
        $class = get_called_class();
        $temp_this = new $class();
        $primary_key = $temp_this->getIDField();
        return self::search()->where($primary_key, $slug_parts[0])->execOne();
    }
1216037
public function findOneBySlug($slug)
    {
        $query = $this->createQueryBuilder('c')
            ->where('c.slug = :slug')
            ->setParameter('slug', $slug)
            ->andWhere('c.publishAt < :now OR c.publishAt IS NULL')
            ->andWhere('c.active = :active')
            ->andWhere('c.layout = :layout')
            ->setParameter('now', new \DateTime())
            ->setParameter('active', true)
            ->setParameter('layout', false)
            ->setMaxResults(1)
            ->getQuery();

        return $query->useResultCache(true, self::CACHE_TTL)->getOneOrNullResult();
    }
553703
def currentVersion(self):
        
        if self._currentVersion is None:
            self.__init(self._url)
        return self._currentVersion