;ò h!ÍBc@s dklZdklZlZdklZdklZdk l Z dk l Z dk Z dkZdklZdklZd klZyd klZWnd „ZnXhd d <dd<dd<dd<dd<dess max_rows_iès cache_time_is max_cache_ids class_name_ss class_file_stemplate_classs SQLMethodcBs}tZeZeZd„Zd„Zddddded„Zd„Zd „Z ddd „Z d „Z d „Z d „Z RS(NcCsm||_t|iiƒ|_d|_x?tiƒD]1\}}t ||ƒ ot |||ƒq4q4WdS(Ns( scontextsselfsstrs __class__s__name__sidstitles _defaultssitemssksvshasattrssetattr(sselfscontextsksv((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pys__init__ s   cCs¥|i}t|ƒ|_t|ƒ}||_ti|ƒ|_t |tt fƒ ot|ƒ}n||_ |i |ƒ|_ }|iƒhtƒf|_dS(såChange database method properties The 'connection_id' argument is the id of a database connection that resides in the current folder or in a folder above the current folder. The database should understand SQL. The 'arguments' argument is a string containing an arguments specification, as would be given in the SQL method cration form. The 'template' argument is a string containing the source for the SQL Template. N(sselfscontextsstrs connection_ids argumentss arguments_srcsAqueductsparses_args isinstancestemplatesunicodessrcstemplate_classstscooksBuckets_v_query_cache(sselfs connection_ids argumentsstemplatestscontext((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pysedit(s      ièidiscCs|i}t|ƒtdƒj ot|ƒ}nt|ƒtdƒj ot|ƒ}nt|ƒtdƒj ot|ƒ}nt|ƒ}t|ƒ}||_ ||f\|_ |_ ht ƒf|_||f\|_|_t|i|idƒ|_dS(s Change advanced properties The arguments are: max_rows -- The maximum number of rows to be returned from a query. max_cache -- The maximum number of results to cache cache_time -- The maximum amound of time to use a cached result. class_name -- The name of a class that provides additional attributes for result record objects. This class will be a base class of the result record class. class_file -- The name of the file containing the class definition. The class file normally resides in the 'Extensions' directory, however, the file name may have a prefix of 'product.', indicating that it should be found in a product directory. For example, if the class file is: 'ACMEWidgets.foo', then an attempt will first be made to use the file 'lib/python/Products/ACMEWidgets/Extensions/foo.py'. If this failes, then the file 'Extensions/ACMEWidgets.foo.py' will be used. iN(sselfscontextstypesmax_rowssatois max_caches cache_timesstrs class_names class_files max_rows_s max_cache_s cache_time_sBuckets _v_sql_caches class_name_s class_file_sgetBrains _v_sql_brain(sselfsmax_rowss max_caches cache_times class_names class_filesREQUESTscontext((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pys advanced_editAs      cCsš|i} t| dƒo | i}nhtƒf}| _|\}}| i} t ƒ} | | i } t |ƒ| djo•|iƒ}|iƒx||o!t |ƒ| jp|d| joL|d}||}||=t||dƒ|jo ||=n|d=q—Wn|i|ƒo)||\} }| | jo|SqLnt|i|ƒ}| i djo$||t| ƒ<| |f||%s cannot be found.sDatabase Errors!%s is not connected to a databaseN( sselfscontextsgetattrs connection_idsdbcsAttributeErrorsDB__s ConflictErrorsid(sselfsDB__scontextsdbc((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pys_get_dbc”s  cKs²|i}|iƒ\}} t}|i|ƒ}d|d<|i |d|ƒqÆW|d |f}nt?|||tƒ}|i@ƒ}|o ||iBjo ||_Bn|o||fSn|SdS(sCall the database method The arguments to the method should be passed via keyword arguments, or in a single mapping object. If no arguments are given, and if the method was invoked through the Web, then the method will try to acquire and use the Web REQUEST object as the argument mapping. The returned value is a sequence of record objects. ss sql_delimiters sql_quote__sclients'client' may not be used as an sargument name in this contexts db_encodings site_encodingusUTF-8ismsgsDatabase query failedsreraiseis _v_sql_brainsN(Csselfscontexts_get_dbcsdbcsDB__sNonesps_argdataskwsargdatas sql_quote__sapplystemplatesquerys TypeErrorsmsgsstrsfinds NameErrors__traceback_info__ssrc__sgets db_encodingsportal_propertiesssite_propertiessdefault_charsets site_encodingsAttributeErrorsKeyErrorssyssgetdefaultencodingstypesencodesUnicodeEncodingErrors cache_time_s max_cache_s_cached_results max_rows_sresults ConflictErrorslog_excshasattrs _v_sql_brainsbrainsgetBrains class_file_s class_name_sStringIOsfswritesseeksRDBsFilesencoded_resultsrowscolumnsscols isinstancestypess StringTypesunicodesnewcolsappendsResultss_searchable_result_columnsstest__s_col(sselfssrc__stest__skwsdbcsargdatasKeyErrorsresultsquerysnewcolsmsgsrows db_encodingsDB__scontexts__traceback_info__sbrainsencoded_resultsfs site_encodingspscolumnsscol((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pys__call__©s†              cCsP|iƒ\}}y|iƒWn)tj o ‚ntddƒnXdS(NsmsgsDatabase abort failed(sselfs_get_dbcsdbcsDB__s tpc_aborts ConflictErrorslog_exc(sselfsDB__sdbc((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pysabort"scCs9|i}t||iƒott||iƒdƒSdS(Ns connected(sselfscontextshasattrs connection_idsgetattr(sselfscontext((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pysconnectionIsValid+s cCs)|i}tt||iƒdƒƒSdS(Ns connected(sselfscontextsgetattrs connection_id(sselfscontext((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pys connected0s (s__name__s __module__sNones_args_cols__init__sedits advanced_edits_cached_results_get_dbcs__call__sabortsconnectionIsValids connected(((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pys SQLMethods  2 ! y (sProducts.Archetypes.debugslog_excsShared.DC.ZRDBsAqueductsRDBsShared.DC.ZRDB.ResultssResultssShared.DC.ZRDB.DAsSQLsApp.ExtensionssgetBrains cStringIOsStringIOssysstypessZODB.POSExceptions ConflictErrorsstringsatoistimesIOBTreesBuckets _defaultss BaseQuerys SQLMethod(ssysstimesStringIOsAqueducts _defaultssRDBsBucketsResultssgetBrains ConflictErrorsatoistypessSQLs SQLMethodslog_exc((sC/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/SQLMethod.pys?s         <