Overriding @@captcha view in collective.captcha

2 messages Options
Embed this post
Permalink
Mikel Larreategi () Overriding @@captcha view in collective.captcha
Reply Threaded More More options
Print post
Permalink
Hi:

We are using collective.captcha 1.3 in production in some Plone 2.5.5
sites and we had to add an override of the browser view
collective.captcha adds in its browser/configure.zcml.

After adding collective.captcha in the eggs and zcml section of our
buildout, and adding the captcha showing snippet in the page template as
follows:

  <p tal:replace="structure here/@@captcha/image_tag" />

We got the following error in our zope instance::

2008-12-12 15:25:42 ERROR Zope.SiteErrorLog
http://dantzan.cs/albisteak/dancilla-youtubera-heldu-da/newsitem_view
Traceback (innermost last):
   Module ZPublisher.Publish, line 115, in publish
   Module ZPublisher.mapply, line 88, in mapply
   Module ZPublisher.Publish, line 41, in call_object
   Module Shared.DC.Scripts.Bindings, line 311, in __call__
   Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
   Module Products.CMFCore.FSPageTemplate, line 195, in _exec
   Module Products.CacheSetup.patch_cmf, line 28, in FSPT_pt_render
   Module Products.CacheSetup.patch_utils, line 9, in call_pattern
   Module Products.CMFCore.FSPageTemplate, line 134, in pt_render
   Module Products.CacheSetup.patch_cmf, line 74, in PT_pt_render
   Module Products.CacheSetup.patch_utils, line 9, in call_pattern
   Module Products.PageTemplates.PageTemplate, line 104, in pt_render
    - <FSPageTemplate at /plone2/newsitem_view used for
/plone2/albisteak/dancilla-youtubera-heldu-da>
   Module TAL.TALInterpreter, line 238, in __call__
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 749, in do_useMacro
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 457, in do_optTag_tal
   Module TAL.TALInterpreter, line 442, in do_optTag
   Module TAL.TALInterpreter, line 437, in no_tag
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 780, in do_defineSlot
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 457, in do_optTag_tal
   Module TAL.TALInterpreter, line 442, in do_optTag
   Module TAL.TALInterpreter, line 437, in no_tag
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 728, in do_defineMacro
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 772, in do_defineSlot
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 728, in do_defineMacro
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 457, in do_optTag_tal
   Module TAL.TALInterpreter, line 442, in do_optTag
   Module TAL.TALInterpreter, line 437, in no_tag
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 749, in do_useMacro
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 715, in do_condition
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 715, in do_condition
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 455, in do_optTag_tal
   Module TAL.TALInterpreter, line 437, in no_tag
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 749, in do_useMacro
   Module TAL.TALInterpreter, line 281, in interpret
   Module TAL.TALInterpreter, line 647, in do_insertStructure_tal
   Module Products.PageTemplates.TALES, line 221, in evaluate
    - URL: file:csDantzan/skins/dantzan_templates/captcha_widget.pt
    - Line 22, Column 6
    - Expression: standard:'here/@@captcha/image_tag'
    - Names:
       {'container': <PloneSite at /plone2>,
        'context': <ATNewsItem at
/plone2/albisteak/dancilla-youtubera-heldu-da>,
        'default': <Products.PageTemplates.TALES.Default instance at
0xb70818ec>,
        'here': <ATNewsItem at
/plone2/albisteak/dancilla-youtubera-heldu-da>,
        'loop': <Products.PageTemplates.TALES.SafeMapping object at
0x106230ac>,
        'modules':
<Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at
0xb70ab0ec>,
        'nothing': None,
        'options': {'args': ()},
        'repeat': <Products.PageTemplates.TALES.SafeMapping object at
0x106230ac>,
        'request': <HTTPRequest,
URL=http://dantzan.cs/albisteak/dancilla-youtubera-heldu-da/newsitem_view>,
        'root': <Application at >,
        'template': <FSPageTemplate at /plone2/newsitem_view used for
/plone2/albisteak/dancilla-youtubera-heldu-da>,
        'traverse_subpath': [],
        'user': <PropertiedUser 'erral'>}
   Module Products.PageTemplates.Expressions, line 185, in __call__
   Module Products.PageTemplates.Expressions, line 173, in _eval
   Module Products.PageTemplates.Expressions, line 127, in _eval
    - __traceback_info__: here
   Module Products.PageTemplates.Expressions, line 313, in
restrictedTraverse
    - __traceback_info__: {'path': ['@@captcha', 'image_tag'],
'TraversalRequestNameStack': []}
Unauthorized: You are not allowed to access 'image_tag' in this context




We had to add an overrides.zcml file to our product and there, add the
following ZCML snippet:

   <browser:page
       name="captcha"
       for="*"
       permission="zope2.Public"
 
allowed_interface="collective.captcha.browser.interfaces.ICaptchaView"
       class="collective.captcha.browser.captcha.Captcha"
       />


Now the captcha view works as expected and the image is shown in the
template.

Is this a bug or something that just happens with our configuration?

Our product versions:
Plone 2.5.5,
CMF-1.6.4,
Zope (Zope 2.9.8-final, python 2.4.5, linux2),
Five 1.4.2,
Python 2.4.5 (#2, Aug 1 2008, 02:20:59) [GCC 4.3.1],
PIL 1.1.6

Best regards,


Mikel Larreategi



--
Mikel Larreategi
[hidden email]

CodeSyntax
Azitaingo Industrialdea 3 K
E-20600 Eibar
Tel: (+34) 943 82 17 80


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
sonu205 () Re: Overriding @@captcha view in collective.captcha
Reply Threaded More More options
Print post
Permalink
Hi,

I am using Plone 3.2.2. I have installed the collective.captcha using buildout, installed successfully.

But I am not able to see this in the Add/Remove product under the control panel.

Now as per the instruction given here http://www.codesyntax.com/cs-workshop/blog/using-collective.captcha-in-custom-forms, I did all the steps. When I submit my Join Form,  where I have added the captach, it takes me to login page and there is no error.

If I add the overrides.zcml in my product with the following lines

 <browser:page
    name="captcha"
    for="*"
    permission="zope2.Public"
    allowed_interface="collective.captcha.browser.interfaces.ICaptchaView"
    class="collective.captcha.browser.captcha.Captcha"
    />

I get this error on all plone sites after restarting plone:

Site Error

An error was encountered while publishing this resource.

TraversalError
Sorry, a site error occurred.

Traceback (innermost last):

    * Module ZPublisher.Publish, line 202, in publish_module_standard
    * Module Products.LinguaPlone.patches, line 67, in new_publish
    * Module ZPublisher.Publish, line 150, in publish
    * Module Zope2.App.startup, line 221, in zpublisher_exception_hook
    * Module ZPublisher.Publish, line 119, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 42, in call_object
    * Module Shared.DC.Scripts.Bindings, line 313, in __call__
    * Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
    * Module Products.CMFCore.FSPageTemplate, line 216, in _exec
    * Module Products.CMFCore.FSPageTemplate, line 155, in pt_render
    * Module Products.Gloworm, line 28, in pt_render
    * Module zope.pagetemplate.pagetemplate, line 117, in pt_render
      Warning: Macro expansion failed
      Warning: zope.traversing.interfaces.TraversalError: ('No traversable adapter found', {u'master': [('version', '1.6'), ('mode', 'html'), ('setPosition', (1, 0)), ('setSourceFile', 'file:d:\\plone\\buildout-cache\\eggs\\plone-3.2.2-py2.4.egg\\Products\\CMFPlone\\skins\\plone_prefs\\prefs_main_template.pt'), ('beginScope', {u'define-macro': u'master'}), ('optTag', (u'metal:page', None, 'metal', 0, [('startTag', (u'metal:page', [(u'define-macro', u'master', 'metal')]))], [('rawtextColumn', (u'\n ', 2)), ('setPosition', (2, 2)), ('useMacro', (u'here/main_template/macros/master', <PathExpr standard:u'here/main_template/macros/master'>, {u'top_slot': [('setPosition', (4, 4)), ('setSourceFile', 'file:d:\\plone\\buildout-cache\\eggs\\plone-3.2.2-py2.4.egg\\Products\\CMFPlone\\skins\\plone_prefs\\prefs_main_template.pt'), ('beginScope', {u'tal:define': u"dummy python:request.set('disable_border',1)", u'fill-slot': u'top_slot'}), ('setLocal', (u'dummy', <PythonExpr request.set('disable_border',1)>)), ('optTag', (u'metal:block', None, 'metal', 1, [('startEndTag', (u'metal:block', [(u'fill-slot', u'top_slot', 'metal'), (u'tal:define', u"dummy python:request.set('disable_border',1)", 'tal')]))], [])), ('endScope', ())], u'column_one_slot': [('setPosition', (7, 4)), ('setSourceFile', 'file:d:\\plone\\buildout-cache\\eggs\\plone-3.2.2-py2.4.egg\\Products\\CMFPlone\\skins\\plone_prefs\\prefs_main_template.pt'), ('beginScope', {u'fill-slot': u'column_one_slot'}), ('optTag', (u'metal:override', None, 'metal', 0, [('startTag', (u'metal:override', [(u'fill-slot', u'column_one_slot', 'metal')]))], [('rawtextColumn', (u'\n ', 8)), ('setPosition', (8, 8)), ('defineSlot', (u'column_one_slot', [('beginScope', {u'define-slot': u'column_one_slot'}), ('optTag', (u'metal:override', None, 'metal', 0, [('startTag', (u'metal:override', [(u'define-slot', u'column_one_slot', 'metal')]))], [('rawtextColumn', (u'\n ', 12)), ('setPosition', (9, 12)), ('useMacro', (u'here/portlet_prefs/macros/portlet', <PathExpr standard:u'here/portlet_prefs/macros/portlet'





Please help!

Thanks,
Sonu