Commits

Cristian Ciupitu  committed cddd9b1

import_validator: use rsplit instead of rindex

rsplit makes the code for satchmo.apps.product.utils.import_validator cleaner

rctay: If '.' is not found, we still get a ValueError as we fail to get
a sufficiently long list (import_name, function_name).

  • Participants
  • Parent commits b6e0f09

Comments (0)

Files changed (1)

File satchmo/apps/product/utils.py

 
 def import_validator(validator):
     try:
-        i = validator.rindex('.')
-        function_name = validator[i+1:]
-        import_name = validator[:i]
+        import_name, function_name = validator.rsplit('.', 1)
     except ValueError:
         # no dot; treat it as a global
         func = globals().get(validator, None)