Squid url redirector

Check-in [b16bc5d76f]
anonymous

Check-in [b16bc5d76f]

Overview
Comment:fixed dump restoration (NULL fields)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: b16bc5d76f47fdf05c0d325e79ce6f6e36bad5b06a5c85f8cd3a6ae485660abd
User & Date: c.kworr@d4daf22a-8aaf-11de-a64d-234b64dd91b4 on 2010-03-25 15:56:45.000
Other Links: branch diff | manifest | tags
Context
2010-07-14
13:50
* removed unneeded check on rules * added possibility to specify masks check-in: 1fa8a88371 user: c.kworr@d4daf22a-8aaf-11de-a64d-234b64dd91b4 tags: master, trunk
2010-03-25
15:56
fixed dump restoration (NULL fields) check-in: b16bc5d76f user: c.kworr@d4daf22a-8aaf-11de-a64d-234b64dd91b4 tags: master, trunk
2010-03-22
15:32
added sorting by site check-in: c27c7eb208 user: c.kworr@d4daf22a-8aaf-11de-a64d-234b64dd91b4 tags: master, trunk
Changes
132
133
134
135
136
137
138
139

140
141
142
143

144
145
146
147
148
149
150
132
133
134
135
136
137
138

139
140
141
142

143
144
145
146
147
148
149
150







-
+



-
+







-- this function adds tag to domain
CREATE or replace FUNCTION mark(domain text, new_tag text) RETURNS integer
	LANGUAGE sql immutable STRICT
	AS $$
select mark(get_site($1), $2) as result;
$$;

-- this function sets tags for site/regexp pair
-- this function sets tags for site without regexp
CREATE or replace FUNCTION set(my_id_site integer, my_id_tag integer) RETURNS integer
	LANGUAGE sql STRICT
	AS $$
delete from urls where $1 = id_site and regexp is null;
delete from urls where $1 = id_site and regexp is NULL;
insert into urls (id_site, id_tag) values ($1, $2);
select $1;
$$;

-- this function sets tags for site/regexp pair
CREATE or replace FUNCTION set(my_id_site integer, my_id_tag integer, my_regexp text) RETURNS integer
	LANGUAGE sql STRICT
35
36
37
38
39
40
41
42
43
44
45
46
47
48


49



50

51
52
53
54
55
56
57
35
36
37
38
39
40
41

42
43
44
45
46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
61







-






+
+

+
+
+
-
+







				config['user'],
				config['password'],
				config['host'],
				config['database'],
		) )

	def load(self, csv_data):
		insert = self._db.prepare("select set($1, $2, $3)")
		with self._db.xact():
			config.section('loader')
			if config['drop_database']:
				self._db.execute('delete from urls;')
				if config['drop_site']:
					self._db.execute('delete from site;');
			insertreg = self._db.prepare("select set($1, $2, $3)")
			insert = self._db.prepare("select set($1, $2)")
			for row in csv_data:
				if len(row[2]) > 0:
					insertreg(row[0], row[1], row[2])
				else:
				insert(row[0], row[1], row[2])
					insert(row[0], row[1])
		self._db.execute('vacuum analyze site;')
		self._db.execute('vacuum analyze urls;')

# this classes processes config file and substitutes default values
class Config:
	__slots__ = frozenset(['_config', '_default', '_section'])
	_default = {