source: products/qPloneCaptchas/tags/1.3.1/skins/captchas_sendto_form/2.0.5/sendto.cpy

Last change on this file was 3, checked in by crchemist, 19 years ago

initial import

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1## Controller Python Script "sendto"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind state=state
7##bind subpath=traverse_subpath
8##parameters=
9##title=Send an URL to a friend
10##
11REQUEST=context.REQUEST
12
13from Products.CMFPlone import transaction_note
14from Products.CMFCore.utils import getToolByName
15from ZODB.POSException import ConflictError
16
17plone_utils = getToolByName(context, 'plone_utils')
18site_properties = getToolByName(context, 'portal_properties').site_properties
19
20# need to check visible state of 'sendto' action in portal_actions
21# but I couldn't figure out how - update collector issue #1490
22# when implemented
23at = getToolByName(context, 'portal_actions')
24
25#if not sendto_action.visible :
26if 0:
27    return state.set(
28        status='failure',
29        portal_status_message='You are not allowed to send this link.')
30
31# Try to find the view action. If not found, use absolute_url()
32url = context.absolute_url()
33ti = context.getTypeInfo()
34if ti is not None:
35    view = ti.getActionById('view', '')
36    if view:
37        url = '/'.join((url, view))
38
39variables = {'send_from_address' : REQUEST.send_from_address,
40             'send_to_address'   : REQUEST.send_to_address,
41             'url'               : url,
42             'title'             : context.Title(),
43             'description'       : context.Description(),
44             'comment'           : REQUEST.get('comment', None)
45             }
46
47try:
48    plone_utils.sendto( variables )
49except ConflictError:
50    raise
51except: #XXX To many things could possibly go wrong. So we catch all.
52    exception = context.plone_utils.exceptionString()
53    return state.set(status='failure', portal_status_message=exception)
54
55tmsg='Sent page %s to %s' % (url, REQUEST.send_to_address)
56transaction_note(tmsg)
57
58return state.set(portal_status_message='Mail sent.')
Note: See TracBrowser for help on using the repository browser.