Index: quintagroup.pfg.captcha/tags/1.0.2/MANIFEST.in
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/MANIFEST.in	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/MANIFEST.in	(revision 2791)
@@ -0,0 +1,3 @@
+recursive-include docs *
+recursive-include quintagroup *
+global-exclude *pyc
Index: quintagroup.pfg.captcha/tags/1.0.2/README.txt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/README.txt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/README.txt	(revision 2791)
@@ -0,0 +1,60 @@
+Introduction
+============
+
+Quintagroup PloneFormGen Captcha Field (quintagroup.pfg.captcha) allows to 
+add captcha field to PloneFormGen forms.
+
+
+Usage
+-----
+
+To add captcha to PloneFormGen forms you need to install 2 Plone products:
+
+* PloneFormGen - for creating the form itself
+* Quintagroup PloneFormGen CaptchaField - for adding captcha field to the form, it will be installed together with Quintagroup Captcha Core (quintagroup.captcha.core) package that enables Plone captchas on Plone sites.
+
+Make sure you install PloneFormGen first, otherwise quintagroup.pfg.captcha may fail to work correctly.
+
+quintagroup.pfg.captcha plugs to PloneFormGen forms, so after successful installation
+you will have a new field among fields available for PloneFormGen form - Captcha Field. 
+Everything you need to do is to select this field from 'Add..' drop-down menu and save it.
+
+
+Supported Plone version
+-----------------------
+
+* 3.x
+
+quintagroup.pfg.captcha was tested with Plone 3.0.6, 3.1.7, 3.2.3, and 3.3.4.
+
+Links
+-----
+    
+* Documentation - http://projects.quintagroup.com/products/wiki/quintagroup.pfg.captcha
+* SVN Repository - http://svn.quintagroup.com/products/quintagroup.pfg.captcha
+
+
+Notes
+-----
+
+* If you want to change captcha look - use quintagroup.captcha.core settings: http://projects.quintagroup.com/products/wiki/quintagroup.captcha.core
+
+* If you want captcha for Plone default forms - use quintagroup.plonecaptchas product http://projects.quintagroup.com/products/wiki/quintagroup.plonecaptchas
+
+* Migration from qPloneCaptchaField: just replace old Products.qPloneCaptchaField with
+  quintagroup.pfg.captcha in the buildout and install new package with quickinstaller -
+  it will replace all old ones captcha fields (qPloneCaptchaField's) with new one.
+
+
+Authors
+-------
+
+The product is developed by Quintagroup.com team:
+
+* Volodymyr Cherepanyak
+* Taras Melnychuk
+* Andriy Mylenkyi
+* Vitaliy Stepanov
+
+Copyright (c) "Quintagroup": http://quintagroup.com, 2004-2010
+
Index: quintagroup.pfg.captcha/tags/1.0.2/docs/HISTORY.txt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/docs/HISTORY.txt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/docs/HISTORY.txt	(revision 2791)
@@ -0,0 +1,22 @@
+Changelog
+=========
+
+1.0.2 (2010-09-08)
+------------------
+
+* import error fixed [chervol]
+
+
+1.0.1 (2010-08-10)
+------------------
+
+* Added migration from qPloneCaptchaField
+  [mylan]
+* Added test for migration
+  [mylan]
+
+
+1.0 (2010-04-19)
+----------------
+
+* Initial release
Index: quintagroup.pfg.captcha/tags/1.0.2/docs/INSTALL.txt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/docs/INSTALL.txt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/docs/INSTALL.txt	(revision 2791)
@@ -0,0 +1,57 @@
+Installation
+============
+
+Quintagroup PloneFormGen CaptchaField should be installed only after PloneFormGen, 
+otherwise it might fail to work correctly.
+
+quintagroup.pfg.captcha on Buildout
+-----------------------------------
+
+To install quintagroup.pfg.captcha to your buildout-based project:
+
+* Add ``quintagroup.pfg.captcha`` to the list of eggs to install::
+
+    [buildout]
+    ...
+    eggs =
+        ...
+        quintagroup.pfg.captcha
+       
+* Tell the plone.recipe.zope2instance recipe to install a ZCML slug::
+
+    [instance]
+    recipe = plone.recipe.zope2instance
+    ...
+    zcml =
+        quintagroup.pfg.captcha
+      
+* Re-run buildout, e.g. with::
+
+    $ ./bin/buildout
+    
+* Restart the Zope server, e.g with the following command in the terminal::
+
+   $ ./bin/instance restart
+   
+* Install ``quintagroup.pfg.captcha`` with Quickinstaller in Plone (Site Setup -> Add/Remove Products) 
+        
+	
+quintagroup.pfg.captcha on Traditional Zope 2 instance
+------------------------------------------------------
+
+To install quintagroup.pfg.captcha into the global Python environment (or a workingenv),
+using a traditional Zope 2 instance, you can do this:
+
+* Copy ``quintagroup`` folder to your instance's ``/lib/python`` directory.
+
+* Create a file called ``quintagroup.pfg.captcha-configure.zcml`` in your instance's ``/etc/package-includes`` directory. The file
+should only contain this::
+
+    <include package="quintagroup.pfg.captcha" />
+
+* Restart the Zope server, for example with the following command in the terminal::
+
+   $ ./bin/zopectl restart
+
+* Install ``quintagroup.pfg.captcha`` with Quickinstaller in Plone (Site Setup -> Add/Remove Products) 
+
Index: quintagroup.pfg.captcha/tags/1.0.2/docs/LICENSE.GPL
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/docs/LICENSE.GPL	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/docs/LICENSE.GPL	(revision 2791)
@@ -0,0 +1,225 @@
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
Index: quintagroup.pfg.captcha/tags/1.0.2/docs/LICENSE.txt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/docs/LICENSE.txt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/docs/LICENSE.txt	(revision 2791)
@@ -0,0 +1,16 @@
+  quintagroup.pfg.captcha is copyright Quintagroup
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+  MA 02111-1307 USA.
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/__init__.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/__init__.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/__init__.py	(revision 2791)
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/__init__.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/__init__.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/__init__.py	(revision 2791)
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/README.txt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/README.txt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/README.txt	(revision 2791)
@@ -0,0 +1,40 @@
+Quintagroup PloneFormGen Captcha Field (quintagroup.pfg.captcha) allows to add captcha field to PloneFormGen forms.
+
+Usage
+
+  To add captcha to PloneFormGen forms you need to install PloneFormGen first (for creating the form itself). After that install Quintagroup PloneFormGen CaptchaField (for adding captcha field to the forms), it will be installed together with Quintagroup Captcha Core (quintagroup.captcha.core) package that enables Plone captchas on Plone sites.
+
+  Make sure you install PloneFormGen first, otherwise quintagroup.pfg.captcha may fail to work correctly.
+
+  quintagroup.pfg.captcha plugs to PloneFormGen forms, so after successful installation you will have a new field among fields available for PloneFormGen form - Captcha Field. Everything you need to do is to select this field from 'Add..' drop-down menu and save it.
+
+Supported Plone version
+
+  Plone 3.x
+
+Links
+   
+  * Documentation - http://projects.quintagroup.com/products/wiki/quintagroup.pfg.captcha
+
+  * SVN Repository - http://svn.quintagroup.com/products/quintagroup.pfg.captcha
+
+Notes
+
+  * If you want to change captcha look - use quintagroup.captcha.core settings: http://projects.quintagroup.com/products/wiki/quintagroup.captcha.core
+
+  * If you want captcha for Plone default forms - use quintagroup.plonecaptchas product http://projects.quintagroup.com/products/wiki/quintagroup.plonecaptchas
+
+Authors
+
+  The product was developed by Quintagroup.com team:
+
+  * Volodymyr Cherepanyak
+
+  * Taras Melnychuk
+
+  * Andriy Mylenkyi
+
+  * Vitaliy Stepanov
+
+
+Copyright (c) "Quintagroup": http://quintagroup.com, 2004-2010
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/__init__.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/__init__.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/__init__.py	(revision 2791)
@@ -0,0 +1,21 @@
+from Products.CMFCore import utils
+from Products.Archetypes.atapi import process_types, listTypes
+
+from config import PROJECTNAME
+from config import ADD_PERMISSION
+
+from field import CaptchaField
+from widget import CaptchaWidget
+from validator import CaptchaValidator
+
+def initialize(context):
+
+    content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME)
+
+    utils.ContentInit(
+        PROJECTNAME + ' Content',
+        content_types      = content_types,
+        permission         = ADD_PERMISSION,
+        extra_constructors = constructors,
+        fti                = ftis,
+        ).initialize(context)
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/config.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/config.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/config.py	(revision 2791)
@@ -0,0 +1,5 @@
+from Products.CMFCore import permissions as cmfcore_permissions
+
+PROJECTNAME = "quintagroup.pfg.captcha"
+
+ADD_PERMISSION = cmfcore_permissions.AddPortalContent
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/configure.zcml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/configure.zcml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/configure.zcml	(revision 2791)
@@ -0,0 +1,23 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:five="http://namespaces.zope.org/five"
+    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
+    xmlns:cmf="http://namespaces.zope.org/cmf"
+    i18n_domain="quintagroup.pfg.captcha">
+
+    <include package="quintagroup.captcha.core" />
+    <include package="Products.PloneFormGen" />
+    
+    <five:registerPackage package="." initialize=".initialize" />
+    <cmf:registerDirectory name="qplonecaptchafield"  directory="skins" recursive="True" />
+
+    <genericsetup:registerProfile
+       name="default"
+       title="Quintagroup PloneFormGen CaptchaField"
+       directory="profiles/default"
+       description="Installs CaptchaField content type."
+       for ="Products.CMFCore.interfaces.ISiteRoot"
+       provides="Products.GenericSetup.interfaces.EXTENSION"
+       />
+
+</configure>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/field.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/field.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/field.py	(revision 2791)
@@ -0,0 +1,63 @@
+from zope.event import notify
+from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
+from Products.CMFCore.permissions import View
+
+from Products.Archetypes.atapi import *
+from Products.ATContentTypes.content.base import registerATCT
+
+from Products.PloneFormGen.content.fields import FGStringField
+from Products.PloneFormGen.content.fieldsBase import BareFieldSchema
+from Products.PloneFormGen.content.fieldsBase import BaseFormField
+from Products.PloneFormGen.content.fieldsBase import BaseFieldSchemaStringDefault
+
+from quintagroup.pfg.captcha.config import PROJECTNAME
+from quintagroup.pfg.captcha.widget import CaptchaWidget
+
+CAPTCHA_ID = 'key'
+HIDDEN_FIELDS = [
+    'title', 
+    'description',
+    'required', 
+    'hidden', 
+    'fgTDefault', 
+    'fgTEnabled', 
+    'fgDefault',
+    'fgTValidator']
+
+def finalizeCaptchaFieldSchema( schema ):
+    schema['title'].default= 'key'
+    for field in HIDDEN_FIELDS:
+        schema[field].widget.visible = {'view':'invisible','edit':'invisible'}
+
+CaptchaFieldSchema = BaseFieldSchemaStringDefault.copy()
+finalizeCaptchaFieldSchema( CaptchaFieldSchema )
+
+def addCaptchaField(self, id, **kwargs):
+    id = CAPTCHA_ID 
+    obj = CaptchaField(id)
+    notify(ObjectCreatedEvent(obj))
+    self._setObject(id, obj)
+    obj = self._getOb(id)
+    obj.initializeArchetype(**kwargs)
+    notify(ObjectModifiedEvent(obj))
+    return obj.getId()
+
+class CaptchaField(FGStringField):
+
+    _at_rename_after_creation = False
+    schema = CaptchaFieldSchema
+
+    def __init__(self, oid, **kwargs):
+        """ initialize class """
+        BaseFormField.__init__(self, oid, **kwargs)
+
+        # set a preconfigured field as an instance attribute
+        self.fgField = StringField('fg_string_field',
+            searchable=0,
+            required=1,
+            write_permission = View,
+            validators=('isCaptchaCorrect',),
+            widget=CaptchaWidget(),
+            )
+
+registerATCT(CaptchaField, PROJECTNAME)
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/factorytool.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/factorytool.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/factorytool.xml	(revision 2791)
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<object name="portal_factory" meta_type="Plone Factory Tool">
+ <factorytypes>
+  <type portal_type="CaptchaField"/>
+ </factorytypes>
+</object>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/import_steps.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/import_steps.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/import_steps.xml	(revision 2791)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<import-steps>
+ <import-step id="migrateToPackage" version="20100720-01"
+              handler="quintagroup.pfg.captcha.setuphandlers.migrateToPackage"
+              title="Collect old Products.qPloneCaptchaFields fields">
+    Collect old Products.qPloneCaptchaFields fields.
+ </import-step>
+ <import-step id="typeinfo" version="20040630-01"
+              handler="Products.CMFCore.exportimport.typeinfo.importTypesTool"
+              title="Types Tool">
+  <dependency step="componentregistry"/>
+  <dependency step="migrateToPackage"/>
+    Import types tool's type information objects.
+ </import-step>
+ <import-step id="afterTypesTool" version="20100720-01"
+              handler="quintagroup.pfg.captcha.setuphandlers.afterTypesTool"
+              title="Migrate old Products.qPloneCaptchaField to quintagroup.pfg.captcha fields">
+  <dependency step="typeinfo"/>
+    Migrate old Products.qPloneCaptchaField to quintagroup.pfg.captcha fields.
+ </import-step>
+</import-steps>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/metadata.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/metadata.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/metadata.xml	(revision 2791)
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<metadata>
+  <version>0.3</version>
+  <dependencies>
+    <dependency>profile-Products.PloneFormGen:default</dependency>
+    <dependency>profile-quintagroup.captcha.core:default</dependency>
+  </dependencies>
+</metadata>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/propertiestool.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/propertiestool.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/propertiestool.xml	(revision 2791)
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<object name="portal_properties" meta_type="Plone Properties Tool">
+ <object name="navtree_properties" meta_type="Plone Property Sheet">
+  <property name="metaTypesNotToList" type="lines" purge="False">
+   <element value="CaptchaField"/>
+  </property>
+ </object>
+</object>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/quintagroup.pfg.captcha_default.txt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/quintagroup.pfg.captcha_default.txt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/quintagroup.pfg.captcha_default.txt	(revision 2791)
@@ -0,0 +1,1 @@
+#
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/quintagroup_pfg_captcha.txt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/quintagroup_pfg_captcha.txt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/quintagroup_pfg_captcha.txt	(revision 2791)
@@ -0,0 +1,1 @@
+#
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/skins.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/skins.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/skins.xml	(revision 2791)
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<object name="portal_skins" meta_type="Plone Skins Tool">
+    <object name="qplonecaptchafield" meta_type="Filesystem Directory View"
+            directory="quintagroup.pfg.captcha:skins/qplonecaptchafield"/>
+    <skin-path name="*">
+        <layer name="qplonecaptchafield" insert-after="custom" />
+    </skin-path>
+</object>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types.xml	(revision 2791)
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<object name="portal_types" meta_type="Plone Types Tool">
+    <object name="CaptchaField"
+          meta_type="Factory-based Type Information with dynamic views" />
+</object>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types/CaptchaField.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types/CaptchaField.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types/CaptchaField.xml	(revision 2791)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<object name="CaptchaField"
+        meta_type="Factory-based Type Information with dynamic views"
+        xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+    <property name="title">Captcha Field</property>
+    <property
+             name="description">Extension for PloneFormGen. Field that prevents automatic page submit.</property>
+    <property name="content_icon">captcha_field.gif</property>
+    <property name="content_meta_type">CaptchaField</property>
+    <property name="product">quintagroup.pfg.captcha</property>
+    <property name="factory">addCaptchaField</property>
+    <property name="immediate_view">base_view</property>
+    <property name="global_allow">False</property>
+    <property name="filter_content_types">True</property>
+    <property name="allowed_content_types"/>
+    <property name="allow_discussion">False</property>
+    <property name="default_view">base_view</property>
+    <property name="view_methods">
+        <element value="base_view"/>
+    </property>
+    <property name="default_view_fallback">False</property>
+    <alias from="(Default)" to="(dynamic view)"/>
+    <alias from="edit" to="atct_edit"/>
+    <alias from="index.html" to="(dynamic view)"/>
+    <alias from="properties" to="base_metadata"/>
+    <alias from="sharing" to="folder_localrole_form"/>
+    <alias from="view" to="(selected layout)"/>
+    <action title="View" action_id="view" category="object" condition_expr=""
+            url_expr="string:${object_url}" visible="True">
+        <permission value="View"/>
+    </action>
+    <action title="Edit" action_id="edit" category="object" condition_expr=""
+            url_expr="string:${object_url}/edit" visible="True">
+        <permission value="Modify portal content"/>
+    </action>
+</object>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types/FormFolder.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types/FormFolder.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/types/FormFolder.xml	(revision 2791)
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<object name="FormFolder" meta_type="Factory-based Type Information"
+        xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+    <property name="allowed_content_types">
+        <element value="Document" />
+        <element value="FieldsetFolder" />
+        <element value="FormBooleanField" />
+        <element value="FormCustomScriptAdapter" />
+        <element value="FormDateField" />
+        <element value="FormFileField" />
+        <element value="FormFixedPointField" />
+        <element value="FormIntegerField" />
+        <element value="FormLabelField" />
+        <element value="FormLinesField" />
+        <element value="FormMailerAdapter" />
+        <element value="FormMultiSelectionField" />
+        <element value="FormPasswordField" />
+        <element value="FormRichLabelField" />
+        <element value="FormRichTextField" />
+        <element value="FormSaveDataAdapter" />
+        <element value="FormSelectionField" />
+        <element value="FormStringField" />
+        <element value="FormTextField" />
+        <element value="FormThanksPage" />
+        <element value="Image" />
+        <element value="CaptchaField" />
+    </property>
+</object>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/workflows.xml
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/workflows.xml	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/profiles/default/workflows.xml	(revision 2791)
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<object name="portal_workflow" meta_type="Plone Workflow Tool">
+ <bindings>
+  <type type_id="CaptchaField">
+    <bound-workflow workflow_id=""/>
+  </type>
+ </bindings>
+</object>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/setuphandlers.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/setuphandlers.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/setuphandlers.py	(revision 2791)
@@ -0,0 +1,40 @@
+import logging
+from zope.component import queryMultiAdapter
+
+logger = logging.getLogger('quintagroup.pfg.captcha')
+
+captcha_fields = []
+
+def migrateToPackage(context):
+    """Collect old Products.qPloneCaptchaFields fields (before types tool setup).
+    """
+    global captcha_fields
+    if context.readDataFile('quintagroup.pfg.captcha_default.txt') is None:
+        return
+
+    site = context.getSite()
+    plone_tools = queryMultiAdapter((site, site.REQUEST), name="plone_tools")
+    ptypes = plone_tools.types()
+    cftype = getattr(ptypes, 'CaptchaField', None)
+    if cftype and getattr(cftype, 'product', "") == "qPloneCaptchaField":
+        catalog = plone_tools.catalog()
+        captcha_fields = [(cf.id, cf.getObject().aq_parent) \
+                          for cf in catalog.search({'portal_type':'CaptchaField'})]
+        logger.info("Old Products.qPloneCaptchaField fields collected.")
+
+
+def afterTypesTool(context):
+    """ Replace old qPloneCaptchaField with new quintagroup.pfg.captcha fields
+    (after types tool setup).
+    """
+    global captcha_fields
+
+    if context.readDataFile('quintagroup.pfg.captcha_default.txt') is None:
+        return
+
+    while captcha_fields:
+        cf_id, form = captcha_fields.pop()
+        form.manage_delObjects(cf_id)
+        form.invokeFactory("CaptchaField", cf_id)
+        logger.info("Fixed CaptchaField in '%s'" % form.getId())
+    logger.info("Finish Captcha field fixing")
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/skins/qplonecaptchafield/captchaField_widget.pt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/skins/qplonecaptchafield/captchaField_widget.pt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/skins/qplonecaptchafield/captchaField_widget.pt	(revision 2791)
@@ -0,0 +1,3 @@
+<metal:view_macro define-macro="edit">
+    <div metal:use-macro="here/captcha_widget/macros/captcha"></div>
+</metal:view_macro>
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/skins/qplonecaptchafield/createObject.cpy
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/skins/qplonecaptchafield/createObject.cpy	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/skins/qplonecaptchafield/createObject.cpy	(revision 2791)
@@ -0,0 +1,59 @@
+## Controller Python Script "createObject"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind state=state
+##bind subpath=traverse_subpath
+##parameters=id=None,type_name=None,script_id=None
+##title=
+##
+
+from DateTime import DateTime
+from Products.CMFPlone.utils import transaction_note
+from Products.CMFPlone import PloneMessageFactory as _
+from Products.CMFCore.utils import getToolByName
+REQUEST=context.REQUEST
+
+if type_name == 'CaptchaField':
+    id = 'key'
+
+if id is None:
+    id=context.generateUniqueId(type_name)
+
+if type_name is None:
+    raise Exception, 'Type name not specified'
+
+types_tool = getToolByName(context, 'portal_types')
+
+fti = types_tool.getTypeInfo(type_name)
+
+if not fti.queryMethodID('edit') and \
+   not fti.getActionObject('object/edit'):
+    state.setStatus('success_no_edit')
+
+if context.portal_factory.getFactoryTypes().has_key(type_name):
+    new_url = 'portal_factory/' + type_name + '/' + id
+    if state.getStatus() != 'success_no_edit':
+        new_url = new_url + '/edit'
+    state.set(status='factory', next_action='redirect_to:string:%s'%new_url)
+    # If there's an issue with object creation, let the factory handle it
+    return state
+else:
+    new_id = context.invokeFactory(id=id, type_name=type_name)
+    if new_id is None or new_id == '':
+       new_id = id
+    o=getattr(context, new_id, None)
+    tname = o.getTypeInfo().Title()
+    message = _(u'${tname} has been created.', mapping={u'tname' : tname})
+    transaction_note('Created %s with id %s in %s' % (o.getTypeInfo().getId(), new_id, context.absolute_url()))
+
+if o is None:
+    raise Exception
+
+if script_id:
+    state.setId(script_id)
+
+if message:
+    context.plone_utils.addPortalMessage(message)
+return state.set(context=o)
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/base.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/base.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/base.py	(revision 2791)
@@ -0,0 +1,65 @@
+import re
+import string
+import unittest
+import transaction
+
+from Products.Five import zcml
+from Products.Five import fiveconfigure
+from Testing import ZopeTestCase as ztc
+
+from Products.PloneTestCase.layer import PloneSite
+from Products.PloneTestCase import setup as ptc_setup
+from Products.PloneTestCase import PloneTestCase as ptc
+
+PACKAGES = [
+    'quintagroup.captcha.core',
+    'quintagroup.pfg.captcha',
+]
+REQUIREMENTS = ['PloneFormGen',] + PACKAGES
+
+ptc.setupPloneSite()
+
+class NotInstalled(PloneSite):
+    """ Only package register, without installation into portal
+    """
+    @classmethod
+    def setUp(cls):
+        fiveconfigure.debug_mode = True
+        import quintagroup.pfg.captcha
+        zcml.load_config('configure.zcml', quintagroup.pfg.captcha)
+        fiveconfigure.debug_mode = False
+        ztc.installProduct('PloneFormGen')
+        ztc.installPackage('quintagroup.pfg.captcha')
+        ztc.installPackage('quintagroup.captcha.core')
+
+    @classmethod
+    def tearDown(cls):
+        ptc_setup.cleanupPloneSite(ptc_setup.portal_name)
+
+
+class Installed(NotInstalled):
+    """ Install product into the portal
+    """
+    @classmethod
+    def setUp(cls):
+        app = ztc.app()
+        portal = app[ptc_setup.portal_name]
+
+        # Sets the local site/manager
+        ptc_setup._placefulSetUp(portal)
+        # Install PROJECT
+        qi = getattr(portal, 'portal_quickinstaller', None)
+        qi.installProduct("quintagroup.pfg.captcha")
+        transaction.commit()
+
+    @classmethod
+    def tearDown(cls):
+        ptc_setup._placefulTearDown()
+        
+
+class TestCase(ptc.PloneTestCase):
+    layer = Installed
+
+
+class TestCaseNotInstalled(ptc.PloneTestCase):
+    layer = NotInstalled
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/testInstalled.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/testInstalled.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/testInstalled.py	(revision 2791)
@@ -0,0 +1,151 @@
+from base import *
+
+from Products.CMFCore.permissions import View
+from Products.Archetypes.atapi import StringField
+from Products.Archetypes.Registry import availableWidgets
+from Products.validation import validation
+
+from quintagroup.pfg.captcha import CaptchaField
+from quintagroup.pfg.captcha import CaptchaWidget
+from quintagroup.pfg.captcha import CaptchaValidator
+from quintagroup.pfg.captcha.widget import CAPTCHA_MACRO
+from quintagroup.pfg.captcha.field import CAPTCHA_ID, HIDDEN_FIELDS
+
+_marker = object()
+
+class TestInstallations(TestCase):
+
+    def testInstalledProducts(self):
+        qi = self.portal.portal_quickinstaller
+        installed = [p['id'] for p in qi.listInstalledProducts()]
+        for p in REQUIREMENTS:
+            if p.startswith('Products'):
+                p = p[9:]
+            self.assertEqual(p in installed, True,
+                '"%s" product not installed' % p)
+
+    def testType(self):
+        pt = self.portal.portal_types
+        self.assertEqual("CaptchaField" in pt.objectIds(), True)
+
+    def testPortalFactory(self):
+        pf = self.portal.portal_factory
+        self.assertEqual("CaptchaField" in pf.getFactoryTypes(), True)
+
+    def testWorkflow(self):
+        pw = self.portal.portal_workflow
+        default_chain = pw.getDefaultChain()
+        cf_chain = pw.getChainForPortalType('CaptchaField')
+        self.assertNotEqual(cf_chain == default_chain , True)
+
+    def testNotToList(self):
+        navtree = self.portal.portal_properties.navtree_properties
+        mtNotToList = navtree.getProperty("metaTypesNotToList")
+        self.assertEqual('CaptchaField' in mtNotToList, True)
+
+    def testSkins(self):
+        ps = self.portal.portal_skins
+        self.assertEqual("qplonecaptchafield" in ps.objectIds(), True)
+        for sname, spath in ps.getSkinPaths():
+            paths = filter(None, map(string.strip, spath.split(',')))
+            self.assertEqual("qplonecaptchafield" in paths, True,
+                '"qplonecaptchafield" layer not present in "%s" skin' % sname)
+
+
+class TestCaptchaField(TestCase):
+
+    def afterSetUp(self):
+        self.folder.invokeFactory('FormFolder', 'ff1')
+        self.ff1 = getattr(self.folder, 'ff1')
+        self.ff1.invokeFactory('CaptchaField', 'captcha_field')
+
+    def testId(self):
+        """CaptchaField has always CAPTCHA_ID id."""
+        self.assertEqual(CAPTCHA_ID in self.ff1, True)
+        self.assertNotEqual('captcha_field' in self.ff1, True)
+
+    def testSchema(self):
+        cf = getattr(self.ff1, CAPTCHA_ID)
+        schema = cf.Schema()
+        for field in HIDDEN_FIELDS:
+            visibility = schema[field].widget.visible
+            self.assertEqual(visibility, {'view':'invisible','edit':'invisible'},
+                '"%s" field is not hidden, but %s:' % (field, visibility))
+
+    def testFGField(self):
+        cf = getattr(self.ff1, CAPTCHA_ID)
+        fgField = getattr(cf, 'fgField', _marker)
+        self.assertNotEqual(fgField, _marker)
+        # Test fgField properties
+        self.assertEqual(type(fgField), StringField)
+        self.assertEqual(bool(fgField.searchable), False )
+        self.assertEqual(fgField.write_permission, View)
+        self.assertEqual(type(fgField.widget), CaptchaWidget)
+        validators = [v.__class__ for v in fgField.validators._chain]
+        self.assertEqual(CaptchaValidator in validators, True)
+
+
+class TestCaptchaWidget(TestCase):
+
+    CF = CaptchaField.__module__ + '.CaptchaField'
+    CW = CaptchaWidget.__module__ + '.CaptchaWidget'
+
+    def afterSetUp(self):
+        self.widgets = dict(availableWidgets())
+
+    def testRegistration(self):
+        self.assertEqual(self.CW in self.widgets, True)
+        cw = self.widgets[self.CW]
+        self.assertEqual(self.CF in cw.used_for, True)
+
+    def testWidgetMacro(self):
+        widget_macro = self.widgets[self.CW].klass._properties['macro']
+        self.assertEqual(widget_macro, CAPTCHA_MACRO)
+
+    def testWidgetMacroAccessable(self):
+        macro = self.portal.restrictedTraverse(CAPTCHA_MACRO)
+        self.assertNotEqual(macro, None)
+
+
+class TestCaptchaValidator(TestCase):
+
+    def getValidator(self):
+        return validation.validatorFor('isCaptchaCorrect')        
+
+    def testRegistration(self):
+        self.assertEqual(self.getValidator().__class__, CaptchaValidator)
+
+    def patchCoreValidator(self, status, error=""):
+        # Patch quintagroup.catpcha.core' captcha_validator
+        class MockState:
+            def __init__(self, status, error=""):
+                self.status = status
+                self.errors = {'key':[error,]}
+
+        patch_validator = lambda : MockState(status, error)
+        self.portal.captcha_validator = patch_validator
+
+    def testValidationSuccess(self):
+        # PFG validator must call patched quintagroup.captcha.core'
+        # captcha_validator and successfully validate the data.
+        validator = self.getValidator()
+        self.patchCoreValidator("success")
+        result = validator('test', instance=self.portal)
+        self.assertEqual(result, 1)
+        
+    def testValidationFailure(self):
+        # PFG validator must call patched quintagroup.captcha.core'
+        # captcha_validator and return error.
+        validator = self.getValidator()
+        self.patchCoreValidator("failure", "Wrong value")
+        result = validator('test', instance=self.portal)
+        self.assertEqual(result, "Wrong value")
+
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(TestInstallations))
+    suite.addTest(unittest.makeSuite(TestCaptchaField))
+    suite.addTest(unittest.makeSuite(TestCaptchaWidget))
+    suite.addTest(unittest.makeSuite(TestCaptchaValidator))
+    return suite
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/testMigration.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/testMigration.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/tests/testMigration.py	(revision 2791)
@@ -0,0 +1,58 @@
+from base import *
+from Products.PloneTestCase.setup import cleanupPloneSite
+from Products.PloneTestCase.setup import portal_name
+from Products.PloneTestCase.setup import SiteCleanup
+
+class TestMigration(TestCaseNotInstalled):
+    """Migration perform recreation old CaptchaField
+    objects from qPloneCaptchaField product to new
+    CaptchaField from quintagroup.pfg.captcha package.
+
+    Migration based on:
+      * presence old portal type CaptchaField with
+        "qPloneCaptchaField" value in *product* field.
+      * presence of CaptchaField objects on the site.
+
+    This TestCase emulate migration with:
+      1. Install new quintagroup.pfg.captcha package
+         and add test CaptchaField object.
+      2. Change *product" field value in
+         portal_tyeps/CaptchaField FTI
+    Then it install quintagroup.pfg.captcha and test if
+    tested CaptchaField object is recreated and *product*
+    field for portal_type/CaptchaField is changed to
+    quintagroup.pfg.captcha.
+    """
+
+    def afterSetUp(self):
+        self.loginAsPortalOwner()
+        self.qi = self.portal.portal_quickinstaller
+        self.pt = self.portal.portal_types
+        self.prepareToMigration()
+
+    def beforeTearDown(self):
+        self.qi.uninstallProducts(["quintagroup.pfg.captcha",])
+
+    def prepareToMigration(self):
+        # Install types
+        self.addProduct("quintagroup.pfg.captcha")
+        # Add captcha field
+        self.portal.invokeFactory("FormFolder", 'test_form')
+        test_form = self.portal['test_form']
+        test_form.invokeFactory("CaptchaField", 'test_captcha_field')
+        self.cf_path = "test_form/key"
+        self.old_cf = self.portal.unrestrictedTraverse(self.cf_path) 
+        self.assert_(self.old_cf)
+        self.pt['CaptchaField'].manage_changeProperties(product="qPloneCaptchaField")
+        self.qi.manage_delObjects('quintagroup.pfg.captcha')
+
+    def testMigration(self):
+        self.addProduct("quintagroup.pfg.captcha")
+        new_cf = self.portal.unrestrictedTraverse(self.cf_path) 
+        self.assert_(self.old_cf != new_cf)
+
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(TestMigration))
+    return suite
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/validator.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/validator.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/validator.py	(revision 2791)
@@ -0,0 +1,31 @@
+from Products.CMFCore.utils import getToolByName
+from Products.validation import validation
+from Products.validation.interfaces.IValidator import IValidator
+from zope.interface import implements
+
+from Products.CMFPlone.utils import safe_hasattr
+
+class CaptchaValidator:
+
+    implements(IValidator)
+
+    name = 'CaptchaValidator'
+    title = ""
+    description = ""
+
+    def __init__(self, name, title='', description=''):
+        self.name = name
+        self.title = title or name
+        self.description = description
+
+    def __call__(self, value, *args, **kwargs):
+
+        form  = kwargs.get('instance')
+        portal = getToolByName(form, 'portal_url').getPortalObject()
+        result = portal.captcha_validator()
+        if result.status == 'failure':
+            return ("%(problem)s" % {'problem' : result.errors['key'][0]})
+        else:
+            return 1
+
+validation.register(CaptchaValidator('isCaptchaCorrect'))
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/version.txt
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/version.txt	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/version.txt	(revision 2791)
@@ -0,0 +1,1 @@
+0.3
Index: quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/widget.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/widget.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/quintagroup/pfg/captcha/widget.py	(revision 2791)
@@ -0,0 +1,15 @@
+from Products.Archetypes.Widget import StringWidget
+from Products.Archetypes.Registry import registerWidget
+
+CAPTCHA_MACRO = "captchaField_widget"
+
+class CaptchaWidget(StringWidget):
+    _properties = StringWidget._properties.copy()
+    _properties.update( {'macro' : CAPTCHA_MACRO} )
+
+
+registerWidget(CaptchaWidget,
+               title = 'Captcha widget',
+               description= ('Renders captcha image and string input',),
+               used_for = ('quintagroup.pfg.captcha.field.CaptchaField',)
+              )
Index: quintagroup.pfg.captcha/tags/1.0.2/setup.cfg
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/setup.cfg	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/setup.cfg	(revision 2791)
@@ -0,0 +1,3 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
Index: quintagroup.pfg.captcha/tags/1.0.2/setup.py
===================================================================
--- quintagroup.pfg.captcha/tags/1.0.2/setup.py	(revision 2791)
+++ quintagroup.pfg.captcha/tags/1.0.2/setup.py	(revision 2791)
@@ -0,0 +1,44 @@
+from setuptools import setup, find_packages
+import os
+
+version = '1.0.2'
+
+setup(name='quintagroup.pfg.captcha',
+      version=version,
+      description="quintagroup.pfg.captcha is a package that allows to add captcha field to PloneFormGen forms.",
+      long_description=open("README.txt").read() + "\n" +
+                       open(os.path.join("docs", "HISTORY.txt")).read(),
+      # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
+      classifiers=[
+        "Framework :: Plone",
+        "Programming Language :: Python",
+        "Topic :: Software Development :: Libraries :: Python Modules",
+        ],
+      keywords='plone captcha PloneFormGen',
+      author='Quintagroup',
+      author_email='support@quintagroup.com',
+      url='http://projects.quintagroup.com/products/wiki/quintagroup.pfg.captcha',
+      license='GPL',
+      packages=find_packages(exclude=['ez_setup']),
+      namespace_packages=['quintagroup', 'quintagroup.pfg'],
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+          'setuptools',
+          'quintagroup.captcha.core',
+          'Products.PloneFormGen',
+          # -*- Extra requirements: -*-
+          # 'zope.event',
+          # 'zope.lifecycleevent',
+          # 'Products.CMFCore',
+          # 'Products.CMFPlone',
+          # 'Products.Archetypes',
+          # 'Products.ATContentTypes',
+          # 'Products.validation',
+      ],
+      entry_points="""
+      # -*- Entry points: -*-
+      [z3c.autoinclude.plugin]
+      target = plone
+      """,
+      )
