---------- Forwarded message ----------
From: Joshua Bronson <[email protected]>
Date: Tue, Feb 10, 2009 at 11:34 AM
Subject: Re: [Melkjug SVN Commits] melkjug r2045 - in melkjug/
branches/opt: . melkjug/controllers
To: Luke Tucker <[email protected]>, [email protected]
hey luke,
thanks for tuning this up. the recursive call in the for loop rather
than the len(..) == 1 check is much nicer. wanted to ask about the
following change:
- operator, operands = value.pop(0), value
+ operator, operands = value[0], value[1:]
I had actually originally written it the second way, but then
realized that the first way is more space-efficient and equally time-
efficient. did you change it because the second way is clearer and
it won't matter with small lists?
On Tue, Feb 10, 2009 at 11:23 AM, <[email protected]> wrote:
Author: ltucker
Date: 2009-02-10 11:23:45 -0500 (Tue, 10 Feb 2009)
New Revision: 2045
Modified:
melkjug/branches/opt/development.ini
melkjug/branches/opt/melkjug/controllers/composite.py
Log:
tune up mixing spec validator
Modified: melkjug/branches/opt/development.ini
===================================================================
--- melkjug/branches/opt/development.ini 2009-02-10 15:53:32
UTC (rev 2044)
+++ melkjug/branches/opt/development.ini 2009-02-10 16:23:45
UTC (rev 2045)
@@ -139,7 +139,7 @@
# Logging configuration
[loggers]
-keys = root, melkjug, minibrain, spider, filter, monolith
+keys = root, melkjug, minibrain, spider, filter, monolith, eval
[handlers]
keys = console
@@ -166,6 +166,11 @@
handlers =
qualname = melk.silo.monolith.lith
+[logger_eval]
+level = INFO
+handlers =
+qualname = melk.model.evaluator
+
[logger_spider]
level = DEBUG
handlers =
@@ -173,7 +178,7 @@
[logger_filter]
level = DEBUG
-handlers =
+handlers =
qualname = minibrain.workers.filterrunner
[handler_console]
Modified: melkjug/branches/opt/melkjug/controllers/composite.py
===================================================================
--- melkjug/branches/opt/melkjug/controllers/composite.py
2009-02-10 15:53:32 UTC (rev 2044)
+++ melkjug/branches/opt/melkjug/controllers/composite.py
2009-02-10 16:23:45 UTC (rev 2045)
@@ -104,26 +104,36 @@
MinLength(2),
MaxLength(128))
-
class FilterFunc(FancyValidator):
messages = {
- 'notlist': 'expected a list with at least two elements',
+ 'badlist': 'expected a list with at least two elements',
'badop': 'Invalid operator "%(op)s',
}
url = URL()
def validate_python(self, value, state):
+
+ # could be just a URL.
if isinstance(value, basestring):
- self.url.to_python(value)
+ self.url.validate_python(value, state)
return
+
+ # otherwise it must be a list starting with an operation,
+ # followed by a bunch of filterfuncs.
if not (isinstance(value, list) and len(value) >= 2):
- raise Invalid(self.message('notlist', state), value,
state)
- operator, operands = value.pop(0), value
+ raise Invalid(self.message('badlist', state), value,
state)
+
+ operator, operands = value[0], value[1:]
+
+ # validate the operation...
if not isinstance(operator, basestring) or not
is_valid_filter_op(operator):
raise Invalid(self.message('badop', state, op=operator),
value, state)
- if len(operands) == 1:
- operands = operands[0]
- self.validate_python(operands, state)
+
+ # and each of the operands....
+ for operand in operands:
+ self.validate_python(operand, state)
+ # sounds good to me....
+
class FilterSchema(Schema):
title = ScrubbedString()
type = URL()
@@ -137,7 +147,7 @@
# MaxLength(128),
# )
revision = Int()
- feeds = ForEach(URL())
+ feeds = ForEach(String())
filters = ForEach(FilterSchema())
allow_extra_fields = True
@@ -232,6 +242,8 @@
try:
MixingSpecSchema.to_python(mixing_spec)
except Invalid:
+ import traceback
+ log.error("Bad mixing spec: [%s]: %s" % (mixing_spec,
traceback.format_exc()))
abort(400)
# Extract feed info and convert into subscriptions...
--
To unsubscribe send an email with subject "unsubscribe" to [email protected]
. Please contact [email protected]
for questions.