[Product Developers] on field validation and calculation
Martin Aspeli
optilude at gmx.net
Thu Mar 22 13:17:30 UTC 2007
Héctor Velarde wrote:
>
> I am trying to add validation to process some fields of ATGoogleVideo
> and ATOdeoAudio products.
>
> the idea is modify the way I ask for video or audio id:
>
> what I have -> what I want
> 4663184974342392861 ->
> http://video.google.com/videoplay?docid=4663184974342392861
> nDxTLUmsR-s -> http://youtube.com/watch?v=nDxTLUmsR-s
> 8721463 -> http://odeo.com/audio/8721463/view
>
> resuming, I want a complete URL instead of a video or audio id only.
>
> in this way I will be able to migrate easier to Plone's 2.5 way of doing
> things and, instead of creating a new content type for every external
> multimedia object, I will only need to add an URL and then display it in
> the correct way.
>
> so what I want to do is: when a URL is entered the validation method
> will validate it and tell me what kind of external multimedia object it
> is. I will add a field to store the result (i.e. Google Video=1 ,
> YouTube=2, Odeo=3...).
>
> can anybody tell me how to do this?
>
I don't quite follow what you are asking for here, but a couple of pointers:
- You can make a new validator easily enough. There are examples in
ATContentTypes, PloneSoftwareCenter and other places.
- You possibly want a validate method instead of a generic validator; if
your field is called "fooBar" then add a method:
def validate_fooBar(self, value):
if value == "the right one":
return None
else:
return "An error message"
- You possibly want a custom mutator method:
def setFooBar(self, value):
# Modify value as you need to
self.getField('fooBar').set(self, value)
Martin
--
View this message in context: http://www.nabble.com/on-field-validation-and-calculation-tf3429785.html#a9611957
Sent from the Plone Product Developers mailing list archive at Nabble.com.
More information about the Product-Developers
mailing list