ó FRTc@s¸ddlmZddlmZddlmZdefd„ƒYZdefd„ƒYZddl Z dd l m Z d e fd „ƒYZ dd l mZd efd„ƒYZdS(iÿÿÿÿ(tprint_function(tSelectResultSet(tsixtDomaincBsÚeZddd„Zd„Zd„Zd„Zd„Zd„Ze dd„Z e d„Z de dd„Z ddd „Zd „Zd de dd „Ze d „Zd„Zd„Zdd„Zd„Zd„ZRS(cCs||_||_d|_dS(N(t connectiontnametNonet _metadata(tselfRR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyt__init__ s  cCs d|jS(Ns Domain:%s(R(R((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyt__repr__%scCst|jd|jƒƒS(NsSELECT * FROM `%s`(titertselectR(R((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyt__iter__(scCsdS(N(R(RRtattrsR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyt startElement+scCs,|dkr||_nt|||ƒdS(Nt DomainName(Rtsetattr(RRtvalueR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyt endElement.s  cCs(|js!|jj|ƒ|_n|jS(N(RRtdomain_metadata(R((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyt get_metadata4s cCs|jj|||||ƒS(sõ Store attributes for a given item. :type item_name: string :param item_name: The name of the item whose attributes are being stored. :type attribute_names: dict or dict-like object :param attribute_names: The name/value pairs to store as attributes :type expected_value: list :param expected_value: If supplied, this is a list or tuple consisting of a single attribute name and expected value. The list can be of the form: * ['name', 'value'] In which case the call will first verify that the attribute "name" of this item has a value of "value". If it does, the delete will proceed, otherwise a ConditionalCheckFailed error will be returned. The list can also be of the form: * ['name', True|False] which will simply check for the existence (True) or non-existence (False) of the attribute. :type replace: bool :param replace: Whether the attribute values passed in will replace existing values or will be added as addition values. Defaults to True. :rtype: bool :return: True if successful (Rtput_attributes(Rt item_namet attributestreplacetexpected_value((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR9s$cCs|jj|||ƒS(sÑ Store attributes for multiple items. :type items: dict or dict-like object :param items: A dictionary-like object. The keys of the dictionary are the item names and the values are themselves dictionaries of attribute names/values, exactly the same as the attribute_names parameter of the scalar put_attributes call. :type replace: bool :param replace: Whether the attribute values passed in will replace existing values or will be added as addition values. Defaults to True. :rtype: bool :return: True if successful (Rtbatch_put_attributes(RtitemsR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR`scCs|jj|||||ƒS(sU Retrieve attributes for a given item. :type item_name: string :param item_name: The name of the item whose attributes are being retrieved. :type attribute_names: string or list of strings :param attribute_names: An attribute name or list of attribute names. This parameter is optional. If not supplied, all attributes will be retrieved for the item. :rtype: :class:`boto.sdb.item.Item` :return: An Item mapping type containing the requested attribute name/values (Rtget_attributes(RRtattribute_nametconsistent_readtitem((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyRuscCs|jj||||ƒS(s Delete attributes from a given item. :type item_name: string :param item_name: The name of the item whose attributes are being deleted. :type attributes: dict, list or :class:`boto.sdb.item.Item` :param attributes: Either a list containing attribute names which will cause all values associated with that attribute name to be deleted or a dict or Item containing the attribute names and keys and list of values to delete as the value. If no value is supplied, all attribute name/values for the item will be deleted. :type expected_value: list :param expected_value: If supplied, this is a list or tuple consisting of a single attribute name and expected value. The list can be of the form: * ['name', 'value'] In which case the call will first verify that the attribute "name" of this item has a value of "value". If it does, the delete will proceed, otherwise a ConditionalCheckFailed error will be returned. The list can also be of the form: * ['name', True|False] which will simply check for the existence (True) or non-existence (False) of the attribute. :rtype: bool :return: True if successful (Rtdelete_attributes(RRRtexpected_values((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR!ˆs#cCs|jj||ƒS(sÖ Delete multiple items in this domain. :type items: dict or dict-like object :param items: A dictionary-like object. The keys of the dictionary are the item names and the values are either: * dictionaries of attribute names/values, exactly the same as the attribute_names parameter of the scalar put_attributes call. The attribute name/value pairs will only be deleted if they match the name/value pairs passed in. * None which means that all attributes associated with the item should be deleted. :rtype: bool :return: True if successful (Rtbatch_delete_attributes(RR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR#®stc Cst||d|d|d|ƒS(s Returns a set of Attributes for item names within domain_name that match the query. The query must be expressed in using the SELECT style syntax rather than the original SimpleDB query language. :type query: string :param query: The SimpleDB query to be performed. :rtype: iter :return: An iterator containing the results. This is actually a generator function that will iterate across all search results, not just the first page. t max_itemst next_tokenR(R(RtqueryR&RR%((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR ÃscCs0|j|d|ƒ}|r(||_|SdSdS(s® Retrieves an item from the domain, along with all of its attributes. :param string item_name: The name of the item to retrieve. :rtype: :class:`boto.sdb.item.Item` or ``None`` :keyword bool consistent_read: When set to true, ensures that the most recent data is returned. :return: The requested item, or ``None`` if there was no match found RN(RtdomainR(RRRR ((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pytget_itemÔs  cCs|jj||ƒS(N(Rtitem_cls(RR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pytnew_itemåscCs|j|jƒdS(N(R!R(RR ((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyt delete_itemèsc Cs’|s"ddlm}|ƒ}ntdd|ƒtd|jd|ƒx|D]}td|jd|ƒxã|D]Û}td|d|ƒ||}t|tƒs³|g}nx‰|D]}tdd d d|ƒt|tjƒrý|jd d ƒ}n!tj|d d ƒjd d ƒ}|j |ƒtdd|ƒqºWtdd|ƒqtWtdd|ƒqPWtdd|ƒ|j ƒ|j dƒ|S(s×Get this domain as an XML DOM Document :param f: Optional File to dump directly to :type f: File or Stream :return: File object where the XML has been dumped to :rtype: file iÿÿÿÿ(t TemporaryFiles&tfiless s s s s s i( ttempfileR-tprintRt isinstancetlistRt text_typetencodetwritetflushtseek(RtfR-R tktvaluesR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pytto_xmlës2      !   cCs/ddl}t|ƒ}|jj||ƒ|S(s)Load this domain based on an XML documentiÿÿÿÿN(txml.saxtDomainDumpParsertsaxtparse(Rtdoctxmlthandler((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pytfrom_xmls  cCs|jj|ƒS(s< Delete this domain, and all items under it (Rt delete_domain(R((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pytdeletesN(t__name__t __module__RR R R RRRtTrueRRtFalseRR!R#R R)R+R,R>RFRH(((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyRs(     &  %     $ tDomainMetaDatacBs&eZdd„Zd„Zd„ZRS(cCsC||_d|_d|_d|_d|_d|_d|_dS(N(R(Rt item_counttitem_names_sizetattr_name_counttattr_names_sizetattr_value_counttattr_values_size(RR(((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR s      cCsdS(N(R(RRRR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR(scCsà|dkrt|ƒ|_n¾|dkr<t|ƒ|_n |dkrZt|ƒ|_n‚|dkrxt|ƒ|_nd|dkr–t|ƒ|_nF|dkr´t|ƒ|_n(|dkrÌ||_nt|||ƒdS(Nt ItemCounttItemNamesSizeBytestAttributeNameCounttAttributeNamesSizeBytestAttributeValueCounttAttributeValuesSizeBytest Timestamp( tintRNRORPRQRRRSt timestampR(RRRR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR+s        N(RIRJRR RR(((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyRMs N(tContentHandlerR@cBs2eZdZd„Zd„Zd„Zd„ZRS(s6 SAX parser for a domain that has been dumped cCs@t|ƒ|_d|_i|_d|_d|_||_dS(NR$(tUploaderThreadtuploaderRtitem_idRt attributeRR((RR(((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyR Ds     cCs]|dkr%|d|_i|_n4|dkrA|d|_n|dkrYd|_ndS(NtItemtidRaRR$(R`RRaR(RRR((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyRLs     cCs|j|7_dS(N(R(Rtch((s</opt/freeware/lib/python2.7/site-packages/boto/sdb/domain.pyt charactersUscCs÷|dkrx|jró|jró|jjƒ}|jjƒ}||jkrb|j|j|ƒqu|g|j|sÿ ,