[email protected] wrote:
I'm working on a product that includes several custom portlets, and
for most of them validation is trivial: Does it have a value, or not?
Today, however, I needed to customize validation for a portlet based on
whether or not a value was a valid URL to a valid RSS 1, 2 or ATOM feed.
That turned out to be surprisingly difficult, and I wonder if I've
stumbled upon a bug.
I kind of doubt that
# I created an exception class to raise the appropriate error:
class InvalidFeed(ValidationError):
"Invalid Feed"
# ... a validation function to test the actual case
# (This version is simplified)
def validateFeed(value):
try:
assert value, value
except AssertionError:
raise InvalidFeed(value)
return True
# ... and the portlet Interface
class IBlogsPortlet(rss.IRSSPortlet):
url = TextLine(
title=u'URL',
description=u'URL of the feed',
required=True,
constraint=validateFeed,
)
...
What's unusual about this is that function validateFeed(value=u'')
gets called when bin/instance fg is run, and of course it throws an
error because value=u'' is not valid, which makes it impossible to start
Zope/Plone. Why would that be?
There is something not in the code above that is calling this code.
Perhaps you have a default value for one of your fields which is being
validated on startup, and the default value is invalid?
Martin
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers