Return public URL to this instance for a given action (default 'view')
435882
def url_for(self, action='view', **kwargs):
        
        app = current_app._get_current_object() if current_app else None
        if app is not None and action in self.url_for_endpoints.get(app, {}):
            endpoint, paramattrs, _external = self.url_for_endpoints[app][action]
        else:
            try:
                endpoint, paramattrs, _external = self.url_for_endpoints[None][action]
            except KeyError:
                raise BuildError(action, kwargs, 'GET')
        params = {}
        for param, attr in list(paramattrs.items()):
            if isinstance(attr, tuple):
                # attr is a tuple containing:
                # 1. ('parent', 'name') --> self.parent.name
                # 2. ('**entity', 'name') --> kwargs['entity'].name
                if attr[0].startswith('**'):
                    item = kwargs.pop(attr[0][2:])
                    attr = attr[1:]
                else:
                    item = self
                for subattr in attr:
                    item = getattr(item, subattr)
                params[param] = item
            elif callable(attr):
                params[param] = attr(self)
            else:
                params[param] = getattr(self, attr)
        if _external is not None:
            params['_external'] = _external
        params.update(kwargs)  # Let kwargs override params

        # url_for from flask
        return url_for(endpoint, **params)
389601
def as_view(cls, action_map=None, **initkwargs):
        

        # Needs to re-implement the method but contains all the things the parent does.
        if not action_map:  # actions must not be empty
            raise TypeError("action_map is a required argument.")

        def view(request):
            self = cls(**initkwargs)
            self.request = request
            self.lookup_url_kwargs = self.request.matchdict
            self.action_map = action_map
            self.action = self.action_map.get(self.request.method.lower())

            for method, action in action_map.items():
                handler = getattr(self, action)
                setattr(self, method, handler)

            return self.dispatch(self.request, **self.request.matchdict)

        return view
151563
def view_getattr():
    

    def view_getattr(_value, context, **_params):
        value = getattr(context["view"], context["key"])
        return _attr(value)

    return view_getattr
1030042
def generate_rest_url(action, object_type, object_id = nil)
      url = custom_url_for(object_type, action)

      method = if action == :list || action == :show
        :get
      elsif action == :create
        :post
      elsif action == :update
        :put
      end

      if url
        url.request_method ||= method
        if object_id
          url.path.sub!(':id', object_id.to_s)
        end
        return url if url
      end

      path = ''
      path += @contexts.collect { |name, value|
        "#{name}/#{value}"
      }.join('/')
      path += '/'
      if action == :list || action == :create
        path += object_type.to_s.pluralize
      elsif action == :show || action == :update
        path += "#{object_type.to_s.pluralize}/#{object_id.to_s}"
      end
      url = generate_url(path)

      ServiceUrl.new(url, method)
    end
453699
def get_view_url(self):
        
        request = self.request
        url = request.getURL()
        qs = request.getHeader("query_string")
        if not qs:
            return url
        return "{}?{}".format(url, qs)
393553
def url(self, action, **kwargs):
        
        # TODO : should be static method ?
        return self.URLS['BASE'] % self.URLS[action] % kwargs
1093526
def GetView(self, viewname):
        

        # Build Request
        soap_request = soap('GetView')
        soap_request.add_parameter('listName', self.listName)

        if viewname == None:
            views = self.GetViewCollection()
            for view in views:
                if 'DefaultView' in view:
                    if views[view]['DefaultView'] == 'TRUE':
                        viewname = view
                        break

        if self.listName not in ['UserInfo', 'User Information List']:
            soap_request.add_parameter('viewName', self.views[viewname]['Name'][1:-1])
        else:
            soap_request.add_parameter('viewName', viewname)
        self.last_request = str(soap_request)

        # Send Request
        response = self._session.post(url=self._url('Views'),
                                      headers=self._headers('GetView'),
                                      data=str(soap_request),
                                      verify=self._verify_ssl,
                                      timeout=self.timeout)

        # Parse Response
        if response.status_code == 200:
            envelope = etree.fromstring(response.text.encode('utf-8'), parser=etree.XMLParser(huge_tree=self.huge_tree))
            view = envelope[0][0][0][0]
            info = {key: value for (key, value) in view.items()}
            fields = [x.items()[0][1] for x in view[1]]
            return {'info': info, 'fields': fields}

        else:
            raise Exception("ERROR:", response.status_code, response.text)
546334
def view_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/views/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
488088
def get_cancel_url(self):
        
        if self.cancel_view:
            url = self.bundle.get_view_url(self.cancel_view,
                                            self.request.user, {},
                                            self.kwargs)
        else:
            url = self.request.build_absolute_uri()

        return self.customized_return_url(url)
654867
def public_api(self,url):
        ''' '''
        try :
            url in api_urls
            return ast.literal_eval(requests.get(base_url + api_urls.get(url)).text)
        except Exception as e:
            print(e)
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
1058384
function chooseViewForRoute() {
            var allParams = addExtraParamsTo(params,
                layoutDelegate,
                serverRequest,
                serverResponse
            );

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

                    return {
                        view: view,
                        reason: null,
                    };
                })
                .catch(function(reason) {
                    return {
                        view: null,
                        reason: reason
                    };
                });
        }
1162094
def _simple_action(self, action=None):
        '''
        '''
        if not action:
            raise Exception('No simple action defined')
        path = "/".join([self.RESOURCE, action])
        response = self.client.request(
            path, {self.RESOURCE_ID_ATTRIBUTE: self.object_id}
        )
        return response
603888
def get_obj_url(request, obj):
    
    if (is_callable(getattr(obj, 'get_absolute_url', None)) and
            (not hasattr(obj, 'can_see_edit_link') or
             (is_callable(getattr(obj, 'can_see_edit_link', None)) and obj.can_see_edit_link(request)))):
        return call_method_with_unknown_input(obj.get_absolute_url, request=request)
    else:
        return get_url_from_model_core(request, obj)
972728
def protected_view(view, info):
    """"""

    if info.options.get('protected'):
        def wrapper_view(context, request):
            response = _advice(request)
            if response is not None:
                return response
            else:
                return view(context, request)
        return wrapper_view
    return view
193337
def get_view(self, request, view_class, opts=None):
        
        kwargs = {}
        if opts:
            if not isinstance(opts, dict):
                opts = opts.__dict__
        else:
            opts = {}

        if not view_class in VALID_MIXIN_OPTIONS:
            valid_options = view_class.__dict__.keys()
            for cls in view_class.__bases__:
                if cls != object:
                    valid_options += cls.__dict__.keys()
            VALID_MIXIN_OPTIONS[view_class] = valid_options

        for key in VALID_MIXIN_OPTIONS[view_class]:
            if key in opts:
                kwargs[key] = opts[key]
            elif hasattr(self, key):
                kwargs[key] = getattr(self, key)

        view = view_class(**kwargs)
        view.request = request
        view.kwargs = {}
        return view
1125584
def get_default_view_path(resource):
    ""

    parts = [a.member_name for a in resource.ancestors] +\
            [resource.collection_name or resource.member_name]

    if resource.prefix:
        parts.insert(-1, resource.prefix)

    view_file = '%s' % '_'.join(parts)
    view = '%s:%sView' % (view_file, snake2camel(view_file))

    app_package_name = get_app_package_name(resource.config)
    return '%s.views.%s' % (app_package_name, view)