Changeset 3685 in products for quintagroup.captcha.core


Ignore:
Timestamp:
Jun 20, 2013 6:54:31 AM (11 years ago)
Author:
vmaksymiv
Message:

added inline validation derector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.captcha.core/trunk/quintagroup/captcha/core/utils.py

    r3600 r3685  
    22import re 
    33import math 
     4import inspect 
     5import operator 
    46try: 
    57    import hashlib as md5 
     
    1214from DateTime import DateTime 
    1315 
     16from plone.memoize import forever 
     17 
    1418from quintagroup.captcha.core.data import basic_english 
    1519#import quintagroup.captcha.core configuration values 
     
    2327except ImportError: 
    2428    import Crypto 
     29 
     30 
     31@forever.memoize 
     32def get_source_file_path(obj): 
     33    return inspect.getsourcefile(obj) 
     34 
     35 
     36def detectInlineValidation(validation_module): 
     37    validation_module_path = get_source_file_path(validation_module) 
     38    path = operator.itemgetter(1) 
     39    return any(path(frame) == validation_module_path 
     40               for frame in inspect.stack()) 
    2541 
    2642 
Note: See TracChangeset for help on using the changeset viewer.