예제 #1
0
 def testAltUrlTurnsStarToAll(self):
     s = ImageSetDesc(graph1, None, "/set?tag=t")
     self.assertEqual(s.altUrl(star='all'), "/set?tag=t")
     s = ImageSetDesc(graph1, None, "/set?tag=t&star=only")
     self.assertEqual(s.altUrl(star='all'), "/set?tag=t")
     s = ImageSetDesc(graph1, None, "/set?tag=t&star=all")
     self.assertEqual(s.altUrl(star='all'), "/set?tag=t")
예제 #2
0
파일: imageSet.py 프로젝트: drewp/photo
    def __init__(self, ctx, graph, uri, **kw):
        """
        uri is the whole page load (relative) uri
        """
        self.graph, self.uri = graph, uri
        agent = getUser(ctx)

        self.desc = ImageSetDesc(graph, agent, uri)
예제 #3
0
파일: access.py 프로젝트: drewp/photo
def expandPhotos(graph, user, subject):
    """
    returns the set of images that this subject refers to, plus a
    short description of the set

    subject can be a photo itself, some search query, a topic, etc
    """

    # this may be redundant with what ImageSetDesc does with one photo?
    if graph.contains((subject, RDF.type, FOAF.Image)):
        return [subject], "this photo"

    #URIRef('http://photo.bigasterisk.com/set?current=http%3A%2F%2Fphoto.bigasterisk.com%2Femail%2F2010-11-15%2FP1010194.JPG&dir=http%3A%2F%2Fphoto.bigasterisk.com%2Femail%2F2010-11-15%2F')
    pics = ImageSetDesc(graph, user, subject).photos()
    if len(pics) == 1:
        return pics, "this photo"
    else:
        return pics, "these %s photos" % len(pics)
예제 #4
0
파일: access.py 프로젝트: drewp/photo
def agentImageSetCheck(graph, agent, photo):
    """
    does this agent (or one of its classes) have permission to
    view some imageset that (currently) includes the image?

    returns an imageset URI or None
    """

    for res in maySee(graph, agent):
        if 'bigasterisk.com/openidProxySite' in res:
            # some other statements about permissions got in the
            # graph; it's wasting time to check them as images
            continue
        log.debug("%r can see %r - is the pic in that set?", agent, res)
        try:
            imgSet = ImageSetDesc(graph, agent, res)
        except ValueError:
            # includes permissions for things that aren't photos at all
            continue
        if imgSet.includesPhoto(photo):
            return maySee
    return None
예제 #5
0
 def testCanonicalErrorsOnRandomParam(self):
     s = ImageSetDesc(graph1, None, "/set?random=10")
     self.assertRaises(ValueError, s.canonicalSetUri)
예제 #6
0
 def testCanonicalIncludesDateParam(self):
     s = ImageSetDesc(graph1, None, "/set?date=2010-11-20")
     self.assertEqual(s.canonicalSetUri(), SITE["set?date=2010-11-20"])
예제 #7
0
 def testCanonicalIncludesStarParam(self):
     s = ImageSetDesc(graph1, None,
                      "/set?dir=http%3A%2F%2Fexample.com%2Fd1&star=only")
     self.assertEqual(
         s.canonicalSetUri(),
         SITE["set?dir=http%3A%2F%2Fexample.com%2Fd1&star=only"])
예제 #8
0
 def testCanonicalIncludesDirParam(self):
     s = ImageSetDesc(graph1, None,
                      "/set?dir=http%3A%2F%2Fexample.com%2Fd1&current=foo")
     self.assertEqual(s.canonicalSetUri(),
                      SITE["set?dir=http%3A%2F%2Fexample.com%2Fd1"])
예제 #9
0
 def testCanonicalOmitsCurrentParam(self):
     s = ImageSetDesc(graph1, None, "/set?tag=t&current=foo")
     self.assertEqual(s.canonicalSetUri(), SITE["set?tag=t"])