[Zope] import error

mlong at datalong.com mlong at datalong.com
Fri Oct 31 13:25:32 EST 2003


Hi,

I must be having a brain freeze. Someone please point out the error of my
ways :) When importing the following module called PValidation I get an
error.

### begin module PValidation.py
from DateTime import DateTime

def validateMoney(input):
	""" Strip leading $ from input and make sure it can be
	converted to a float datatype otherwise return 0 """

	if input == '': input = '0'
	if input[0] == '$': input = input[1:]
	try: float(input)
	except: input = '0'
	return input

def validateDate(input):
	""" If input can be formated by DateTime return formatted
	text otherwise return an empty string """

	try: results = DateTime(input).strftime('%m/%d/%Y')
	except: results = ''
	return results
### End Module

I get this traceback error:

An exception occurred during the last refresh.
Exception type: ImportError
Exception value: cannot import name validateDate

Traceback (most recent call last):
  File "C:\Program Files\Zope-2.7.0-b2\lib\python\App\RefreshFuncs.py",
line 182, in performSafeRefresh
    if not performRefresh(jar, productid):
  File "C:\Program Files\Zope-2.7.0-b2\lib\python\App\RefreshFuncs.py",
line 169, in performRefresh
    Application.reimport_product(productid)
  File "C:\Program Files\Zope-2.7.0-b2\lib\python\OFS\Application.py",
line 767, in reimport_product
    raise_exc=1, log_exc=0)
  File "C:\Program Files\Zope-2.7.0-b2\lib\python\OFS\Application.py",
line 534, in import_product
    product=__import__(pname, global_dict, global_dict, silly)
  File "C:\Zope-PropOrg\Products\PRealEstate\__init__.py", line 5, in ?
    from PRealEstate import PRealEstate, manage_addPRealEstateForm,
manage_addPRealEstate
  File "C:\Zope-PropOrg\Products\PRealEstate\PRealEstate.py", line 21, in ?
    from PParcel import PParcel
  File "C:\Zope-PropOrg\Products\PRealEstate\PParcel.py", line 19, in ?
    from PStructure import PStructure
  File "C:\Zope-PropOrg\Products\PRealEstate\PStructure.py", line 18, in ?
    from PUnitResident import PUnitResident
  File "C:\Zope-PropOrg\Products\PRealEstate\PUnitResident.py", line 18, in ?
    from PLeaseResident import PLeaseResident
  File "C:\Zope-PropOrg\Products\PRealEstate\PLeaseResident.py", line 20,
in ?
    from Products.PUtils.PValidation import validateMoney, validateDate
ImportError: cannot import name validateDate




More information about the Zope mailing list