Redirect to the add view if no records exist or the change
        view if the singleton instance exists.
502010
def changelist_view(self, *args, **kwargs):
        
        try:
            singleton = self.model.objects.get()
        except self.model.MultipleObjectsReturned:
            return super(SingletonAdmin, self).changelist_view(*args, **kwargs)
        except self.model.DoesNotExist:
            return redirect(admin_url(self.model, "add"))
        return redirect(admin_url(self.model, "change", singleton.id))
995625
def switchCurrentView(self, viewType):
        
        if not self.count():
            return self.addView(viewType)

        # make sure we're not trying to switch to the same type
        view = self.currentView()
        if type(view) == viewType:
            return view

        # create a new view and close the old one
        self.blockSignals(True)
        self.setUpdatesEnabled(False)

        # create the new view
        index = self.indexOf(view)
        if not view.close():
            return None
        #else:
        #    self.tabBar().removeTab(index)

        index = self.currentIndex()
        new_view = viewType.createInstance(self.viewWidget(), self.viewWidget())

        # add the new view
        self.insertTab(index, new_view, new_view.windowTitle())

        self.blockSignals(False)
        self.setUpdatesEnabled(True)
        self.setCurrentIndex(index)

        return new_view
486874
public void handleViewChange(View view, Digest digest) {
        if(gms.isLeaving() && !view.containsMember(gms.local_addr))
            return;
        View prev_view=gms.view();
        gms.installView(view, digest);
        Address prev_coord=prev_view != null? prev_view.getCoord() : null, curr_coord=view.getCoord();
        if(!Objects.equals(curr_coord, prev_coord))
            coordChanged(prev_coord, curr_coord);
    }
253848
public void addNew() throws DBException
    {
        if (((this.getRecord().getOpenMode() & DBConstants.OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY) == 0)
            && ((this.getRecord().getOpenMode() & DBConstants.OPEN_READ_ONLY) != DBConstants.OPEN_READ_ONLY)
            && (this.getRecord().getCounterField() != null))
                this.getRecord().setOpenMode(this.getRecord().getOpenMode() | DBConstants.OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY); // Must have for MirrorTable to sync new records
        super.addNew();
        Iterator<BaseTable> iterator = this.getTables();
        while (iterator.hasNext())
        {
            BaseTable table = iterator.next();
            if ((table != null) && (table != this.getNextTable()))
            {
                table.addNew();
            }
        }
    }
1001003
def changelist_view(self, request, extra_context=None):
        
        model = self.model
        if model.objects.all().count() > 1:
            return super(HTMLSitemapAdmin, self).changelist_view(request)
        else:
            obj = model.singleton.get()
            return redirect(reverse('admin:jmbo_sitemap_%s_change' % \
                    model._meta.module_name, args=(obj.id,)))
261038
def change_view(self, request, object_id, form_url='', extra_context={}):
        
        extra_context['buttons_link'] = self.buttons_link
        extra_context['buttons_form'] = self.buttons_form
        extra_context['button_object_id'] = object_id
        return super(ButtonableModelAdmin, self).change_view(request, object_id, form_url, extra_context)
63109
private void redirectToAccessDeniedView(FacesContext context, UIViewRoot viewRoot) {
        // If a user has already done a redirect and rendered the response (possibly in an observer) we cannot do this output
        final PhaseId currentPhase = context.getCurrentPhaseId();
        if (!context.getResponseComplete() && !PhaseId.RENDER_RESPONSE.equals(currentPhase)) {
            AccessDeniedView accessDeniedView = viewConfigStore.getAnnotationData(viewRoot.getViewId(), AccessDeniedView.class);
            if (accessDeniedView == null || accessDeniedView.value() == null || accessDeniedView.value().isEmpty()) {
                log.warn("No AccessDeniedView is configured, returning 401 response (access denied). Please configure an AccessDeniedView in the ViewConfig.");
                context.getExternalContext().setResponseStatus(401);
                context.responseComplete();
                return;
            }
            String accessDeniedViewId = accessDeniedView.value();
            log.debugf("Redirecting to configured AccessDenied %s", accessDeniedViewId);
            NavigationHandler navHandler = context.getApplication().getNavigationHandler();
            navHandler.handleNavigation(context, "", accessDeniedViewId);
            context.renderResponse();
        }
    }
507894
private void handleTmpView(View v) {
        Address new_coord=v.getCoord();
        if(new_coord != null && !new_coord.equals(coord) && local_addr != null && local_addr.equals(new_coord))
            handleViewChange(v);
    }
1304044
function (view) {
    view.base = view.base || view.cwd || process.cwd();
    this.src = this.src || {};
    // ensure that `view` has `path` and `content` properties
    this.validate(view);

    this.options.orig = view.content;
    this.options.plural = this.collection.options.plural;
    this.options.viewType = this.options.viewType = [];
    this.options.handled = this.options.handled = [];

    this.contexts = view.contexts = {};
    this.locals = view.locals || {};
    this.data = view.data || {};
    mixins(this);

    // add non-emumerable properties
    this.defineOption('route', this.options.route);
    this.define('_callbacks', this._callbacks);

    if (view.stat) {
      utils.defineProp(view, 'history', view.history);
      utils.defineProp(view, '_contents', view._contents);
      utils.defineProp(view, 'stat', view.stat);
    }

    view.__proto__ = this;
    utils.defineProp(view, '_callbacks', view._callbacks);

    // handle `onLoad` middleware routes
    this.app.handleView('onLoad', view, view.locals);
    this.ctx('locals', view.locals);
    this.ctx('data', view.data);
  }
37997
protected function set_view()
	{
		$this->_view instanceOf View or $this->_view = \View::forge($this->_view);
	}
827112
def _add_redirects(self):
        
        html = '''
        <html>
            <head>
                <meta http-equiv="refresh" content="0;URL={url}"/>
            </head>
            <body>
                <p>
                    The page has been moved to <a href="{url}">{title}</a>
                </p>
            </body>
        <html>
        '''
        with open(REDIRECTS_FILE) as mapping_fd:
            reader = csv.reader(mapping_fd)
            for row in reader:
                if not row or row[0].strip().startswith('#'):
                    continue

                path = os.path.join(BUILD_PATH,
                                    'html',
                                    *row[0].split('/')) + '.html'

                try:
                    title = self._get_page_title(row[1])
                except Exception:
                    # the file can be an ipynb and not an rst, or docutils
                    # may not be able to read the rst because it has some
                    # sphinx specific stuff
                    title = 'this page'

                if os.path.exists(path):
                    raise RuntimeError((
                        'Redirection would overwrite an existing file: '
                        '{}').format(path))

                with open(path, 'w') as moved_page_fd:
                    moved_page_fd.write(
                        html.format(url='{}.html'.format(row[1]),
                                    title=title))
1201208
def view(self, *args, **kwargs):
        
        def decorator(f):
            kwargs.setdefault("view_class", self.view_class)
            return self.add_view(as_view(*args, **kwargs)(f))
        return decorator
1299683
def view_or_add(self, slug):
        '''
        
        '''
        rec_page = MWiki.get_by_uid(slug)

        if rec_page:
            if rec_page.kind == self.kind:
                self.view(rec_page)
            else:
                return False
        else:
            self.to_add(slug)
1330542
def _idle_register_view(self, view):
        """"""
        assert(self.view is None)
        self.view = view

        if self.handlers == "class":
            for name in dir(self):
                when, _, what = partition(name, '_')
                widget, _, signal = partition(what, '__')
                if when == "on":
                    try:
                        view[widget].connect(signal, getattr(self, name))
                    except IndexError:
                        # Not a handler
                        pass
                    except KeyError:
                        logger.warn("Widget not found for handler: %s", name)
        elif self.handlers == "glade":
            self.__autoconnect_signals()
        else:
            raise NotImplementedError("%s is not a valid source of signal "
                "connections" % self.handlers)

        self.register_view(view)
        self.register_adapters()
        if self.__auto_adapt: self.adapt()
        return False
40281
def view_exists?(query)
      if query.nil?
        raise ArgumentError, 'Query cannot be nil'
      end

      result = query(query)

      !result.empty?
    end
821346
def change_view(self, request, object_id, form_url='', extra_context=None):
        
        context = {
            'has_moderate_tool': True
        }
        if extra_context:
            context.update(extra_context)
        return super(AdminModeratorMixin, self).change_view(
            request=request,
            object_id=object_id,
            form_url=form_url,
            extra_context=context
        )
633002
function chooseViewForRoute() {
            var allParams = addExtraParamsTo(params,
                layoutDelegate,
                clientRequest,
                clientResponse
            );

            return promisify(originalHandler).apply(router, allParams)
                .then(function(view) {
                    validateView(view);

                    return {
                        view: view,
                        reason: null
                    };
                })
                .catch(function(reason) {
                    return {
                        view: null,
                        reason: reason
                    };
                });
        }