[Zope] Adding an external method
Özgür Caner
oc@teuto.net
Fri, 06 Jul 2001 15:11:33 +0200
Hi,
the definition of your method is wrong.
Because the external method is a method of the object which contain it.
The correct definition is:
def monthRange (self, dt)
--On Freitag, Juli 06, 2001 14:57:41 +0200 Gitte Wange
<gitte@mmmanager.org> wrote:
> Hello,
>
> I am trying to add an external metod (used in a CMF Calendar example) but
> it fails.
>
> Now I'm not into these external methods (and I am not sure it's the best
> solution) but I just want to see how this example works.
>
> The method file is named monthRange.py and I have placed it in
> /usr/local/Zope/Extensions
> it contains this code:
> from DateTime import DateTime
>
> def monthRange( dt ):
> """
> Return a pair of DateTime values representing the
> earliest and latest times in the month in which 'dt'
> falls.
> """
> y, m, d = dt.year(), dt.month(), dt.day()
> first = DateTime( y, m, 1 )
> last = first - 1 + DateTime._month_len[dt.isLeapYear() ][ m ]
> return first.earliestTime(), last.latestTime()
>
> I have filled in these values in the add form in ZMI:
> Id: monthRange
> Module Name: monthRange
> Function Name: monthRange
>
> I get this error when I try to add it:
> Error Type: SyntaxError
> Error Value: invalid syntax
>
> And this traceback:
> Traceback (innermost last):
> File /usr/local/Zope-2.3.2-linux2-x86/lib/python/ZPublisher/Publish.py,
> line 223, in publish_module
> File /usr/local/Zope-2.3.2-linux2-x86/lib/python/ZPublisher/Publish.py,
> line 187, in publish
> File /usr/local/Zope-2.3.2-linux2-x86/lib/python/Zope/__init__.py, line
> 221, in zpublisher_exception_hook
> File /usr/local/Zope-2.3.2-linux2-x86/lib/python/ZPublisher/Publish.py,
> line 171, in publish
> File /usr/local/Zope-2.3.2-linux2-x86/lib/python/ZPublisher/mapply.py,
> line 160, in mapply
> (Object: manage_addExternalMethod)
> File /usr/local/Zope-2.3.2-linux2-x86/lib/python/ZPublisher/Publish.py,
> line 112, in call_object
> (Object: manage_addExternalMethod)
> File
> /usr/local/Zope-2.3.2-linux2-x86/lib/python/Products/ExternalMethod/Exter
> nalMethod.py, line 131, in manage_addExternalMethod
> File
> /usr/local/Zope-2.3.2-linux2-x86/lib/python/Products/ExternalMethod/Exter
> nalMethod.py, line 179, in __init__
> (Object: monthRange)
> File
> /usr/local/Zope-2.3.2-linux2-x86/lib/python/Products/ExternalMethod/Exter
> nalMethod.py, line 202, in manage_edit
> (Object: monthRange)
> File
> /usr/local/Zope-2.3.2-linux2-x86/lib/python/Products/ExternalMethod/Exter
> nalMethod.py, line 209, in getFunction
> (Object: monthRange)
> File /usr/local/Zope-2.3.2-linux2-x86/lib/python/App/Extensions.py,
> line 217, in getObject
> (Info: ('/usr/local/Zope-2.3.2-linux2-x86/Extensions/monthRange.py',
> 'monthRange'))
> SyntaxError: (see above)
>
> Well it looks like it finds the file.
> To me it looks like there is a syntax error in the add of the external
> method. or is the syntax error in the python code ?
>
> I haven't debugged this kind of scripts before so I hope there is someone
> who can help me :-)
>
> Regards,
>
> --
> Gitte Wange Jensen
>
> Sys Admin, Developer and a lot more
> MMmanager.org Aps, Denmark
>
> Phone: +45 29 72 79 72
> Email: gitte@mmmanager.org
> Web: www.mmmanager.org
>
> Quote of the day:
> Unix is user friendly; it's just a
> little paticular about which users
> it is friendly to.
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )