comparison taginthemiddle/model.py @ 19:57ca873ed9bf default tip

make this a pluggable system and start reorging infrastructure for that
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 25 May 2010 07:48:53 -0700
parents c85d42296c06
children
comparison
equal deleted inserted replaced
18:3bf478cb3166 19:57ca873ed9bf
5 - someone that tagged the resource 5 - someone that tagged the resource
6 """ 6 """
7 7
8 import os 8 import os
9 import time 9 import time
10 from pkg_resources import iter_entry_points
11
12 ### interface
10 13
11 class Tags(object): 14 class Tags(object):
12 """ 15 """
13 abstract base class for tagging 16 abstract base class for tagging
14 """ 17 """
28 31
29 def urls(self, *tags): 32 def urls(self, *tags):
30 """ 33 """
31 get the URLs for a set of tags 34 get the URLs for a set of tags
32 """ 35 """
36
37 def make_tags(string):
38 """
39 Instantiate and return a tag engine from a setuptools entry point
40 - string: "URL" of tagger (e.g. 'file:///path/to/file?author=whoami')
41 """
42
43 # have to split out the schema ourselves or urlparse is too smart for
44 # its own good
45 assert '://' in string # XXX could also not have this for no parameters
46 name, value = string.split('://', 1)
47
48 import pdb; pdb.set_trace()
49
50 ### implementation
33 51
34 class FileTags(Tags): 52 class FileTags(Tags):
35 """ 53 """
36 file (e.g. .ini) based tagging scheme 54 file (e.g. .ini) based tagging scheme
37 55
126 144
127 def urls(self, *tags): 145 def urls(self, *tags):
128 """ 146 """
129 select * from tags where tag='' 147 select * from tags where tag=''
130 """ 148 """
149
150 ### command line
151
152 if __name__ == '__main__':
153 foo = make_tags('file:///tmp/foo.tags?author=bar')