;ò
ðëEc           @   sj   d  Z  d k Td k Td k Td k l Z d k l Z d k Z d k	 Z
 d e e e i f d „  ƒ  YZ d S(   sE   
   Copyright (C) 1999-2006 PimenTech SARL (http://www.pimentech.net)

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.	
(   s   *(   s   CatalogPathAwareness(   s   HTMLFileNs   PgObjectc           B   s‘  t  Z d  Z d Z d Z e Z e i Z	 e
 i Z e d e ƒ  ƒ Z e
 i d e
 i d e
 i d h  d d <d	 d
 <f Z e e i ƒ  ƒ Z e d e e d „ Z d „  Z e Z d „  Z d „  Z d „  Z e d „ Z e d „ Z e d „ Z e Z d „  Z d „  Z d „  Z d „  Z e e d „ Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% g  e d „ Z& d d  „ Z' d! „  Z( h  d" „ Z) d# „  Z* RS($   sb   
	PgObject class
	This object use acquisition from a PgRoot object : if you haven't, use pgroot.
	s   PgObjects   /s   dtml/historyi    i   i   s   labels   Historys   actions   view_historys
   postgresqlc         C   sr   t  | ƒ } | |  _ |  i | | ƒ |  i | ƒ t | p | ƒ |  _	 | p |  i
 |  _
 | p |  i |  _ d  S(   N(   s   strs   ids   initialized_froms   selfs   _initialized_froms   _PgObject__DBP_inits   connection_ids   _PgObject__Map_inits   ints   uids	   meta_types	   tablename(   s   selfs   ids   connection_ids   uids   initialized_froms	   tablenames	   meta_type(    (    s   pgobject.pys   __init__6   s    	c         C   sV   |  i d |  i |  i f ƒ |  i ƒ  |  i d j o t i |  ƒ n |  i ƒ  d S(   s@    Zope method : automaticaly called when an instance is created. s   %s.manage_afterAdd(%s)s	   interfaceN(	   s   selfs   messages	   tablenames   ids   _create_current_rows   _initialized_froms   PgObjects   inserts   _pgobject_update(   s   selfs   ids	   container(    (    s   pgobject.pys   manage_afterAdd?   s     
c         C   s+   |  i ƒ  |  i d |  i |  i f ƒ d S(   s@    Zope method : automaticaly called when an instance is deleted. s   id %s : %s.manage_beforeDeleteN(   s   selfs   unindex_objects   notices   ids	   tablename(   s   selfs   ids	   container(    (    s   pgobject.pys   manage_beforeDeleteM   s     
c         C   së   t  |  d t ƒ o |  i d ƒ d Sn g  } x± |  i D]¦ \ } } | | j o xC |  i	 ƒ  i
 | ƒ D], } | d d j o | i | d ƒ qh qh WxD | D]8 } | | i i |  ƒ j o |  i d | ƒ d SqŸ qŸ Wq9 q9 Wd Sd	 S(
   s.    return true if the method has the permission s   __ac_permissions__s   no __ac_permissions__ !i    s   selecteds   SELECTEDs   names   is allowed with role %s !i   N(   s   getattrs   selfs   Nones   messages   roless   __ac_permissions__s
   permissions   lists   method_names   get_root_apps   rolesOfPermissions   dicts   appends   roles   REQUESTs   AUTHENTICATED_USERs   getRolesInContext(   s   selfs   method_names   REQUESTs   roless
   permissions   lists   dicts   role(    (    s   pgobject.pys
   is_allowedR   s$     
   c         C   sI   |  i |  i ƒ o- t |  i |  i |  i ƒ  ƒ |  |  i <d Sn d Sd S(   sB   Called by PGObject.manage_afterAdd : add the row of self.tablenamei   i    N(   s   selfs   has_keys	   tablenames   PRows   getUid(   s   self(    (    s   pgobject.pys   _create_current_rowd   s
     %c         C   s7   | t j o
 | } n t | | | ƒ } | |  | <d  S(   N(   s   ids   Nones
   table_names   PRows   uids   rows   self(   s   selfs   uids
   table_names   ids   row(    (    s   pgobject.pys   _add_rowk   s    
c         C   s%   |  i | | | ƒ |  | i ƒ  d S(   s&   ajoute une row avec données ds la baseN(   s   selfs   _add_rows   uids
   table_names   ids   update(   s   selfs   uids
   table_names   id(    (    s   pgobject.pys   add_row_from_pgq   s     c         C   sH   x! |  i d ƒ D] } | i ƒ  q W|  i d ƒ |  _ |  i ƒ  d Sd S(   s.    <= Update all rows of pgobject from postgreqls   Rows   ztitles	   update OKN(   s   selfs   objectValuess   rows   updates   get_row_attrs   titles   reindex(   s   selfs   REQUESTs   row(    (    s   pgobject.pys   updatev   s      
c         C   sJ   x? |  i d ƒ D]. } | i o q n d |  _ | i | ƒ q Wd Sd S(   s,    => Update all rows of pgobject to postgreqls   Rowi   s	   commit OKN(   s   selfs   objectValuess   rows   _to_be_commiteds
   _p_changeds   commits   REQUEST(   s   selfs   REQUESTs   row(    (    s   pgobject.pys   commit€   s      	c         C   s6   x! |  i d ƒ D] } | i ƒ  q W|  i ƒ  d Sd S(   s,    => Insert all rows of pgobject to postgreqls   Rows	   insert OKN(   s   selfs   objectValuess   rows   inserts   reindex(   s   selfs   row(    (    s   pgobject.pys   insertŠ   s      
c         C   s2   |  | i ƒ  p |  i | ƒ } | i ƒ  | Sd S(   sB    Update or insert an object from the update function (PostgreSQL) N(   s   selfs   instances   getIds   _add_objects   update(   s   selfs   instance(    (    s   pgobject.pys   _update_or_insert’   s      
c         C   sB   |  i d | i | i ƒ  f ƒ | |  | i ƒ  <|  | i ƒ  Sd S(   s?    Add an objet (used by update_or_insert function) (PostgreSQL) s   select uid from %s where uid=%sN(   s   selfs   fetchones   instances	   tablenames   getUids   getId(   s   selfs   instance(    (    s   pgobject.pys   _add_object˜   s      c         C   sZ   | o | |  i  j o d Sn | p |  i } |  | | } | t j o d Sn | Sd  S(   Ns    (   s	   meta_types   selfs	   tablenames	   attributes   values   None(   s   selfs	   attributes	   tablenames	   meta_types   value(    (    s   pgobject.pys   get_row_attrž   s    c         C   s   |  i Sd S(   s&   returns the value of uid in postgresqlN(   s   selfs   uid(   s   self(    (    s   pgobject.pys   getUid§   s     c         C   s   |  i i ƒ  |  _ x5 |  |  i i ƒ  D]  \ } } t |  d | | ƒ q& W|  i	 p |  i
 |  _ |  i t |  i ƒ |  i j o |  i ƒ  n |  i ƒ  Sd S(   s   reindex catalogs   pg_N(   s   selfs	   aq_parents   getPaths   parent_paths	   tablenames   itemss   keys   values   setattrs	   pg_ztitles   pg_zids   titles
   named_paths   lens   _set_named_paths   reindex_object(   s   selfs   values   key(    (    s   pgobject.pys   reindex«   s      !c         C   s   d |  i i ƒ  |  i f Sd S(   s    Construction of named path s   %s/%sN(   s   selfs	   aq_parents   get_named_paths   title(   s   self(    (    s   pgobject.pys   get_named_pathµ   s     c         C   s   |  i ƒ  |  _ d S(   s   save the named pathN(   s   selfs   get_named_paths
   named_path(   s   self(    (    s   pgobject.pys   _set_named_path¹   s     c         C   s   |  i d ƒ \ } | Sd  S(   Ns    select nextval('object_uid_seq')(   s   selfs   fetchones   val(   s   selfs   val(    (    s   pgobject.pys   _get_next_uid½   s    c         C   s   t  | ƒ t  d ƒ j o | g } n | o t d d d d d d ƒ Sn y |  i } Wn f  } n XxB | D]: } | | j o' t d d d d	 t | ƒ d d ƒ Sqo qo WxÅ | o½ | d
 } |  i	 | |  ƒ } | i ƒ  o t d | i ƒ  ‚ n | |  j o t d t | d
 ƒ ‚ n d t |  | ƒ j o& |  i d | ƒ |  | i | ƒ n |  i | ƒ | d
 =q° W| t j	 o |  i |  | d d ƒSn d S(   sˆ   Delete a subordinate object

		The objects specified in 'ids' get deleted.

		** THIS IN THE FUNCTION FROM OFS/ObjectManager.py **
		
		s    s   titles   No items specifieds   messages   No items were specified!s   actions   ./manage_mains   Not Deletables   <EM>%s</EM> cannot be deleted.iÿÿÿÿs    Object "%s" is locked via WebDAVs   %s does not exists	   delete_mes&   delete_me by manage_delObject on id %ss   update_menui   N(   s   types   idss   MessageDialogs   selfs   _reserved_namess   ps   ns   escapes   ids   _getObs   vs   wl_isLockeds   ResourceLockedErrors   getIds
   BadRequests   dirs   notices	   delete_mes   REQUESTs
   _delObjects   Nones   manage_main(   s   selfs   idss   REQUESTs   vs   ns   ps   id(    (    s   pgobject.pys   manage_delObjectsÁ   s@      	  
 	 
i   c         C   så   |  i d |  i ƒ  |  i i |  i i ƒ  f ƒ | o5 x2 |  i d ƒ D] } d | d <|  i | ƒ qF Wn xM |  i
 ƒ  D]? } d t |  | ƒ j o |  | i | ƒ qx |  i | ƒ qx W|  i i |  i ƒ  ƒ | i i d ƒ Sd S(   s   Delete this object and its rowss8   [pgobject.py(delete_me)] delete object %s in %s named %ss   Rowi   s
   ref_statuts	   delete_mes   .N(   s   selfs   warnings   getIds	   aq_parents	   meta_types   withRowss   objectValuess   rows   commits   REQUESTs	   objectIdss   ids   dirs	   delete_mes
   _delObjects   RESPONSEs   redirect(   s   selfs   REQUESTs   withRowss   ids   row(    (    s   pgobject.pys	   delete_meê   s     / 
 c         C   sY   g  } t |  i ƒ o |  i ƒ  } n
 |  i } x | D] } | i | d ƒ q6 W| Sd S(   sC   Return list of meta_types instead of list of dicts 'all_meta_types's   nameN(   s
   meta_typess   callables   selfs   all_meta_typess   alls	   meta_types   append(   s   selfs	   meta_types   alls
   meta_types(    (    s   pgobject.pys   all_real_meta_typesý   s     	 c         C   sK   |  i ƒ  } |  |  i } | i | | | ƒ |  i | ƒ |  i	 ƒ  | Sd S(   s    duplicate the row N(
   s   selfs   _get_next_uids   uids	   tablenames   rows   _copys   dict_valuess   REQUESTs   commits   reindex(   s   selfs   REQUESTs   dict_valuess   rows   uid(    (    s   pgobject.pys   _copy	  s     
c         C   s$   d |  i | f } |  i | ƒ Sd S(   s*    return all values of a previous pgobject s0   SELECT * FROM %s WHERE uid=%s AND ref_statut!=1 N(   s   selfs	   tablenames   uids   querys   dictfetchone(   s   selfs   uids   query(    (    s   pgobject.pys   sql_history  s     (+   s   __name__s
   __module__s   __doc__s	   meta_types
   named_paths   Nones	   tablenames   DBPs   __init__s   _PgObject__DBP_inits   Maps   _PgObject__Map_inits   HTMLFiles   globalss   view_historys   manage_optionss   types   DateTimes   __date_type__s   manage_afterAdds   _pgobject_manage_afterAdds   manage_beforeDeletes
   is_alloweds   _create_current_rows   _add_rows   add_row_from_pgs   updates   _pgobject_updates   commits   inserts   _update_or_inserts   _add_objects   get_row_attrs   getUids   reindexs   get_named_paths   _set_named_paths   _get_next_uids   manage_delObjectss	   delete_mes   all_real_meta_typess   _copys   sql_history(    (    (    s   pgobject.pys   PgObject    sD    		9						
						
			)		(   s   __doc__s   Products.PimenTechLibCommon.rows   Products.PimenTechLibCommon.maps   Products.PimenTechLibCommon.dbps   Products.ZCatalogs   CatalogPathAwarenesss   Globalss   HTMLFiles   DateTimes   AccessControl.Roles   AccessControls   Maps   DBPs   CatalogAwares   PgObject(   s   AccessControls   PgObjects   HTMLFiles   DateTimes   CatalogPathAwareness(    (    s   pgobject.pys   ?   s   		
