Back to index

plone3  3.1.7
field.py
Go to the documentation of this file.
00001 ##########################################################
00002 #
00003 # Licensed under the terms of the GNU Public License
00004 # (see docs/LICENSE.GPL)
00005 #
00006 # Copyright (c) 2005:
00007 #   - The Open Planning Project (http://www.openplans.org/)
00008 #   - Whit Morriss <whit@kalistra.com>
00009 #   - Rob Miller <rob@kalistra.com> (RaFromBRC)
00010 #   - and contributors
00011 #
00012 ##########################################################
00013 from Products.Archetypes import public as atapi
00014 from Products.Archetypes.Registry import registerField
00015 from Products.Archetypes.interfaces import IBaseObject
00016 from ZPublisher.HTTPRequest import FileUpload
00017 from wicked import utils
00018 from wicked.fieldevent.interfaces import IFieldRenderEvent, IFieldStorageEvent
00019 from wicked.fieldevent.interfaces import ITxtFilterList, IFieldValueSetter
00020 from wicked.interfaces import IAmWicked, IAmWickedField, IValueToString
00021 from wicked.txtfilter import WickedFilter
00022 from zope.component import adapter, adapts
00023 from zope.interface import implements, implementer
00024 from wicked.at.interfaces import IAmATWickedField
00025 from cStringIO import StringIO
00026 
00027 class WikiField(atapi.TextField):
00028     """ drop-in wiki """
00029     implements(IAmWickedField)
00030 
00031     _properties = atapi.TextField._properties.copy()
00032     _properties.update({
00033         'scope': '',
00034         })
00035 
00036 registerField(WikiField,
00037               title='Wiki',
00038               description='Text field capable of wiki style behavior')
00039 
00040 
00041 @implementer(IValueToString)
00042 @adapter(atapi.BaseUnit, IAmATWickedField)
00043 def baseunit_to_string(value, field):
00044     """this avoid a security proxy that will foul regexes"""
00045     return value.getRaw()
00046 
00047 
00048 @implementer(IValueToString)
00049 @adapter(FileUpload, IAmWickedField)
00050 def fileupload_to_string(value, field):
00051     """a file was uploaded, get the (possibly transformed) value"""
00052     # XXX no `instance` defined
00053     return field.get(instance, skip_filters=True)
00054 
00055 
00056