Ñò
+×qKc           @   s}  d  Z  d d d !Z d d d !Z d d d !Z d d k l Z d d	 k l Z d d
 k l	 Z	 d d k
 l
 Z
 d d k l Z l Z l Z l Z l Z l Z l Z d d k Z d d k l Z d d k l Z d d k l Z d d k l Z d d d d d d d „ Z e d e ƒ  ƒ Z d d d d d d d d d „ Z d d d d d d d „ Z d e f d „  ƒ  YZ  e i! e  ƒ d S(   sª  
$RCSfile: DTDValidateMethod.py,v $

ZopeXMLMethods provides methods to apply to Zope objects for XML/XSLT
processing.  DTDValidateMethod tests an XML document for validity
against a schema, where the XML document is obtained from another Zope
object (the 'source' object) via acquisition.

Author: Craeg Strong <cstrong@arielpartners.com>
Release: 1.0

$Id: DTDValidateMethod.py,v 1.1 2003/06/16 05:47:53 arielpartners Exp $
s	   $Name:  $i   iþÿÿÿs   $Date: 2003/06/16 05:47:53 $s   $Revision: 1.1 $i
   iÿÿÿÿ(   t   IDTDValidateMethod(   t   IDTDValidator(   t   ProcessorRegistry(   t   GeneratorRegistry(   t	   XMLMethodt   getPublishedResultt	   PERM_VIEWt	   PERM_EDITt   PERM_FTPt   PERM_CONTENTt   PERM_MANAGEN(   t   MessageDialog(   t   ClassSecurityInfo(   t   PageTemplateFile(   t
   implementst    s
   text/plaini    c         C   s.   |  i  d i | | | | | | | ƒ |  | S(   s	  
    This is a convenience factory method for creating an instance of
    DTDValidateMethod.  It returns the object created, and may therefore be
    more convenient than the addDTDValidateMethod() method it calls.  It is
    used by the unit testing programs.
    t   ZopeXMLMethods(   t   manage_addProductt   addDTDValidateMethod(   t   foldert   idt   titlet   descriptiont   selected_processort   content_typet   behave_liket
   debugLevel(    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyt   addInstance(   s    
s   www/createDTDValidator.ptc
         C   sÉ   y{ |  i  | | | | | | | ƒ d | d }
 | d j o d Sy |  i ƒ  } Wn | d } n X| i i | d ƒ WnG t j
 o; } t | ƒ }
 |
 i d d ƒ t d d	 d
 |
 d d ƒ SXd S(   s¸   
    Factory method to create an instance of DTDValidateMethod, called from
    a GUI in the Zope Management Interface.  It calls addDTDValidateMethod
    to actually do the work.
    s   Successfully created s    DTDValidateMethod object.Nt   URL1s   /manage_mains   
s   <br/>R   t   Errort   messaget   actiont   manage_main(	   R   t   Nonet   DestinationURLt   RESPONSEt   redirectt	   Exceptiont   strt   replaceR   (   t   selfR   R   R   R   R   R   R   t   REQUESTR#   R   t   urlt   e(    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyt   manage_addDTDValidateMethod<   s"    
s	   text/htmlc      
   C   sV   | p t  d ƒ ‚ n |  i | t | | | | | | | ƒ ƒ |  i | ƒ i ƒ  d S(   sÓ   
    Factory method to actually create an instance of DTDValidateMethod
    and return it.

    You should call this method directly if you are creating an
    instance of DTDValidateMethod programatically.
    s!   Required fields must not be blankN(   R%   t
   _setObjectt   DTDValidateMethodt   _getObt   reindex_object(   R(   R   R   R   R   R   R   R   (    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyR   [   s    
R.   c           B   sÂ   e  Z d  Z d Z e e ƒ e ƒ  Z d d d d „ Z e i	 d ƒ d „  Z
 e i	 d ƒ d	 „  Z e i e d
 ƒ d „  Z e i e d ƒ d „  Z e i e d ƒ d d d d „ Z d „  Z RS(   s»   
    DTDValidateMethod tests an XML document for validity against a
    schema, where the XML document is obtained from another Zope
    object (the 'source' object) via acquisition.
    s   DTD Validate Methods	   text/htmlR   i    c      	   C   sF   t  i |  | | | | | | | ƒ |  i p t i t ƒ |  _ n d  S(   N(   R   t   __init__R   R   t   defaultNameR   (   R(   R   R   R   R   R   R   R   (    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyR1   …   s
    

t   availableProcessorsc         C   s   t  i t ƒ S(   sX   
        Return names of currently available DTD validation processor libraries
        (   R   t   namesR   (   R(   (    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyR3   –   s    t	   processorc         C   s   t  i t |  i ƒ S(   sM   
        Obtain the object encapsulating the selected DTD processor.
        (   R   t   itemR   R   (   R(   (    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyR5      s    	t   dtdValidationResultsStringc         C   sV   |  i  ƒ  } |  i ƒ  } t d | | ƒ } | i ƒ  } | i |  i ƒ | i | | ƒ S(   s(   Return results of validation as a strings
   XML source(   R5   t   getXmlSourceObjectR   t   absolute_urlt   setDebugLevelR   R7   (   R(   R)   R5   t	   xmlObjectt   xmlContentst   xmlURL(    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyt   validationResultsString¥   s    	t   isValidc         C   sV   |  i  ƒ  } |  i ƒ  } t d | | ƒ } | i ƒ  } | i |  i ƒ | i | | ƒ S(   sp   
        Return boolean indicating whether passed in document is valid
        with respect to this DTD
        s
   XML source(   R5   R8   R   R9   R:   R   t   isValidForDTD(   R(   R)   R5   R;   R<   R=   (    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyR?   ²   s    t   __call__c         C   sÜ   |  i  | ƒ } |  i d j o |  i ƒ  i } n
 |  i } t i | ƒ } | d j o t i ƒ  } n | d j	 o | i d |  i	 ƒ n | i
 |  i |  i | d |  i	 ƒ} | d j o
 |  } n | i | | | | ƒ S(   sG   
        Render self by validating its content against its DTD
        R   s   Content-TypeR   N(   R>   R   R8   t	   meta_typeR   t   getGeneratorR!   t   getDefaultGeneratort	   setHeaderR   t   createObjectR   R   t	   getResult(   R(   t   clientR)   R#   t	   rawResultR   t   gent   obj(    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyRA   Æ   s    	
c         C   s   d S(   s¿   
        Repair this object.  This method is used for schema migration,
        when the class definition changes and existing instances of
        previous versions must be updated.
        N(    (   R(   (    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyt   repairè   s    N(   t   __name__t
   __module__t   __doc__RB   R   R    R   t	   _securityR1   t   declarePublicR3   R5   t   declareProtectedR   R>   R?   R!   RA   RL   (    (    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyR.   u   s"   
					"("   RO   t
   __cvstag__t   __date__t   __version__t
   interfacesR    t   processors.interfacesR   t   processors.ProcessorRegistryR   R   R   R   R   R   R   R	   R
   t   GlobalsR   t   AccessControlR   t'   Products.PageTemplates.PageTemplateFileR   t   zope.interfaceR   R   t   globalst   manage_addDTDValidateMethodFormR!   R,   R   R.   t   InitializeClass(    (    (    s6   /srv/Zope/Products/ZopeXMLMethods/DTDValidateMethod.pyt   <module>   s8   4	}