code: 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)
docs: Return public URL to this instance for a given action (default 'view')