[Zope] Adding an external method

Norman Khine khine@btinternet.com
Fri, 6 Jul 2001 14:27:51 +0100


Which version of python are you using?

If you are using python 2.1 then from the command prompt if you debug
line-by-line you get an error from

DateTime/DateTime.py:90: DeprecationWarning: the regex module is deprecated;
please use the re module
import sys, os, math, regex, ts_regex, DateTimeZone
/usr/local/lib/python2.1/regsub.py:15: DeprecationWarning: the regsub module
is deprecated; please use re.sub()
  DeprecationWarning)

perhaps this may be the problem

Norman



-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Gitte
Wange
Sent: Friday, July 06, 2001 1:58 PM
To: zope@zope.org
Subject: [Zope] Adding an external method


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/External
Method.py,
line 131, in manage_addExternalMethod
  File
/usr/local/Zope-2.3.2-linux2-x86/lib/python/Products/ExternalMethod/External
Method.py,
line 179, in __init__
    (Object: monthRange)
  File
/usr/local/Zope-2.3.2-linux2-x86/lib/python/Products/ExternalMethod/External
Method.py,
line 202, in manage_edit
    (Object: monthRange)
  File
/usr/local/Zope-2.3.2-linux2-x86/lib/python/Products/ExternalMethod/External
Method.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 )