Allura/allura/lib/plugin.py
def project_from_url(self, url):
        '''Returns a tuple (project, error).

        Where project is the Project instane parsed from url or None if project
        can't be parsed. In that case error will be a string describing the error.
        '''
        from allura.model import Project, Neighborhood
        if url is None:
            return None, u'Empty url'
        url = urlparse(url)
        url = [u for u in url.path.split('/') if u]
        if len(url) == 0:
            return None, u'Empty url'
        if len(url) == 1:
            q = Project.query.find(dict(shortname=url[0]))
            cnt = q.count()
            if cnt == 0:
                return None, u'Project not found'
            if cnt == 1:
                return q.first(), None
            return None, u'Too many matches for project: {}'.format(cnt)
        n = Neighborhood.query.get(url_prefix=u'/{}/'.format(url[0]))
        if not n:
            return None, u'Neighborhood not found'
        p = Project.query.get(neighborhood_id=n._id, shortname=url[1])
        if len(url) > 2:
            # Maybe subproject
            subp = Project.query.get(neighborhood_id=n._id, shortname='{}/{}'.format(*url[1:3]))
            if subp:
                return (subp, None)
        return (p, u'Project not found' if p is None else None)
Returns a tuple (project, error).

        Where project is the Project instane parsed from url or None if project
        can't be parsed. In that case error will be a string describing the error.
        
Returns a tuple (project, error).
Where project is the Project instane parsed from url or None if project
can't be parsed. In that case error will be a string describing the error.
Returns a tuple ( project error ) . Where project is the Project instane parsed from url or None if project can ' t be parsed . In that case error will be a string describing the error .
def project_from_url(self, url):
        from allura.model import Project, Neighborhood
        if url is None:
            return None, u'Empty url'
        url = urlparse(url)
        url = [u for u in url.path.split('/') if u]
        if len(url) == 0:
            return None, u'Empty url'
        if len(url) == 1:
            q = Project.query.find(dict(shortname=url[0]))
            cnt = q.count()
            if cnt == 0:
                return None, u'Project not found'
            if cnt == 1:
                return q.first(), None
            return None, u'Too many matches for project: {}'.format(cnt)
        n = Neighborhood.query.get(url_prefix=u'/{}/'.format(url[0]))
        if not n:
            return None, u'Neighborhood not found'
        p = Project.query.get(neighborhood_id=n._id, shortname=url[1])
        if len(url) > 2:
            subp = Project.query.get(neighborhood_id=n._id, shortname='{}/{}'.format(*url[1:3]))
            if subp:
                return (subp, None)
        return (p, u'Project not found' if p is None else None)
def project_from_url ( self , url ) : from allura . model import Project , Neighborhood if url is None : return None , u'Empty url' url = urlparse ( url ) url = [ u for u in url . path . split ( '/' ) if u ] if len ( url ) == 0 : return None , u'Empty url' if len ( url ) == 1 : q = Project . query . find ( dict ( shortname = url [ 0 ] ) ) cnt = q . count ( ) if cnt == 0 : return None , u'Project not found' if cnt == 1 : return q . first ( ) , None return None , u'Too many matches for project: {}' . format ( cnt ) n = Neighborhood . query . get ( url_prefix = u'/{}/' . format ( url [ 0 ] ) ) if not n : return None , u'Neighborhood not found' p = Project . query . get ( neighborhood_id = n . _id , shortname = url [ 1 ] ) if len ( url ) > 2 : subp = Project . query . get ( neighborhood_id = n . _id , shortname = '{}/{}' . format ( * url [ 1 : 3 ] ) ) if subp : return ( subp , None ) return ( p , u'Project not found' if p is None else None )
Returns a tuple (project, error).
Returns a tuple ( project error ) .
'''Returns a tuple (project, error).

        Where project is the Project instane parsed from url or None if project
        can't be parsed. In that case error will be a string describing the error.
        ''' # Maybe subproject
self
url