This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EC2Object(object): | |
| def __init__(self, connection=None): | |
| self.connection = connection | |
| if self.connection and hasattr(self.connection, 'region'): | |
| self.region = connection.region | |
| else: | |
| self.region = None | |
| def startElement(self, name, attrs, connection): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_snapshot(self, volume_id,descripton=""): | |
| """ | |
| by HDKNR.COM | |
| description : some comment or note for a snapshot | |
| http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSnapshot.html | |
| """ | |
| paramcription = {'VolumeId' : volume_id, 'Description' : description} | |
| return self.get_object('CreateSnapshot', params, Snapshot) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def generate_random_codes(self): | |
| """ | |
| Used to generate random key/secret pairings. | |
| Use this after you've added the other data in place of save(). | |
| """ | |
| key = generate_random(length=KEY_SIZE) | |
| secret = generate_random(length=SECRET_SIZE) | |
| while Consumer.objects.filter(key__exact=key, secret__exact=secret).count(): | |
| secret = generate_random(length=SECRET_SIZE) | |
| self.key = key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _response_to_rss ($resp) { | |
| $rss = new MagpieRSS( $resp->results ); | |
| // if RSS parsed successfully | |
| if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) { | |
| // find Etag, and Last-Modified | |
| foreach( (array) $resp->headers as $h) { | |
| // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" | |
| if (strpos($h, ": ")) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT t.*, tt.* FROM wp_terms AS t | |
| INNER JOIN wp_term_taxonomy AS tt | |
| ON t.term_id = tt.term_id | |
| WHERE tt.taxonomy = 'post_tag' AND t.slug = 'thrudb' LIMIT 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Wordpress : list wp_post entiries tagged with "thrudb" | |
| ; | |
| SELECT SQL_CALC_FOUND_ROWS wp_posts.* | |
| FROM wp_posts | |
| INNER JOIN wp_term_relationships | |
| ON (wp_posts.ID = wp_term_relationships.object_id) | |
| INNER JOIN wp_term_taxonomy | |
| ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) | |
| INNER JOIN wp_terms | |
| ON (wp_term_taxonomy.term_id = wp_terms.term_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # django/contrib/syndication/views.py | |
| # | |
| from django.contrib.syndication import feeds | |
| from django.http import HttpResponse, Http404 | |
| def feed(request, url, feed_dict=None): | |
| if not feed_dict: | |
| raise Http404, "No feeds are registered." | |
| try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # django/db/models.py Manager class | |
| # | |
| ####################### | |
| # PROXIES TO QUERYSET # | |
| ####################### | |
| def get_empty_query_set(self): | |
| return EmptyQuerySet(self.model) | |
| def get_query_set(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class QuerySet(object): | |
| """ | |
| Represents a lazy database lookup for a set of objects. | |
| """ | |
| def __init__(self, model=None, query=None): | |
| self.model = model | |
| self.query = query or sql.Query(self.model, connection) | |
| self._result_cache = None | |
| self._iter = None | |
| self._sticky_filter = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # QuerySet.iterator() | |
| # creating a model class instance ? | |
| if skip: | |
| row_data = row[index_start:aggregate_start] | |
| pk_val = row_data[pk_idx] | |
| obj = model_cls(**dict(zip(init_list, row_data))) | |
| else: | |
| # Omit aggregates in object creation. | |
| obj = self.model(*row[index_start:aggregate_start]) |