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")
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)
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)
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
def testCanonicalErrorsOnRandomParam(self): s = ImageSetDesc(graph1, None, "/set?random=10") self.assertRaises(ValueError, s.canonicalSetUri)
def testCanonicalIncludesDateParam(self): s = ImageSetDesc(graph1, None, "/set?date=2010-11-20") self.assertEqual(s.canonicalSetUri(), SITE["set?date=2010-11-20"])
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"])
def testCanonicalIncludesDirParam(self): s = ImageSetDesc(graph1, None, "/set?dir=http%3A%2F%2Fexample.com%2Fd1¤t=foo") self.assertEqual(s.canonicalSetUri(), SITE["set?dir=http%3A%2F%2Fexample.com%2Fd1"])
def testCanonicalOmitsCurrentParam(self): s = ImageSetDesc(graph1, None, "/set?tag=t¤t=foo") self.assertEqual(s.canonicalSetUri(), SITE["set?tag=t"])