This file contains 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
# In schevo.entity:Entity... | |
@extentmethod | |
@with_selection | |
@with_label(u'Delete Selected') | |
def t_delete_selected(self, selection): | |
tx = schevo.transaction.Combination([ | |
entity.t.delete() for entity in selection | |
]) | |
This file contains 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 EntityClassTransactions(NamespaceExtension): | |
__slots__ = NamespaceExtension.__slots__ | |
def __init__(self, name, instance): | |
NamespaceExtension.__init__(self, name, instance) | |
d = self._d | |
for t_name in instance._t_selectionmethod_names: | |
func = getattr(instance, t_name) | |
name = t_name[2:] |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html | |
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<title>Elements getting chopped off</title> | |
<script src="/js/jquery-1.2.6.js" type="text/javascript" charset="utf-8"></script> | |
<script src="/js/chain-0.2.js" type="text/javascript" charset="utf-8"></script> | |
<script type="text/javascript" charset="utf-8"> |
This file contains 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 Canvas(m.Model): | |
"""A canvas for turtle(s) to draw on. | |
The origin of a canvas is the bottom left of the plane. | |
A heading of 0 degrees points upward. | |
""" | |
class Meta: | |
verbose_name_plural = 'canvases' |
This file contains 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
from schevo.schema import * | |
schevo.schema.prep(locals()) | |
import string | |
class SortedUniqueNames(F.String): | |
"""List of space-separated names, sorted case-insensitively.""" |
This file contains 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
import appscript | |
# Send a message to IRC channel already joined/opened. | |
channel = '#mychannel' | |
message = 'My Message' | |
appscript.app('Adium').chats[channel].send(message=message) | |
This file contains 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
import os | |
import sys | |
from PyQt4 import uic | |
from PyQt4.QtCore import QSize, Qt, QTimer, pyqtProperty, pyqtSignal, pyqtSlot | |
from PyQt4.QtGui import * | |
from PyQt4.QtWebKit import * | |
html = \ | |
"""<html> |
This file contains 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
# The general idea is to attach a sequence to an object upon instantiation. | |
# When creating kwargs to pass to dict(), Python evaluates each expression | |
# in the order written, and thus each Field instance in this example has | |
# a _number attribute that corresponds to the order in which it was written | |
# in source code. | |
class Field(object): | |
_last_number = 0 | |
def __init__(self, **kw): | |
self.__dict__.update(kw) |
This file contains 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
# Here's a way to "snapshot" the modules already loaded by | |
# Python, so you can go back to that snapshot at a later point in | |
# time by causing Python to forget about modules already loaded. | |
# | |
# The modules still exist if you have any objects pointing to them, | |
# but when an import statement or __import__ call is encountered, | |
# Python will look for the module again and load it as if it were | |
# never imported in the first place. | |
# | |
# This is useful when you lazily import modules, such as in the |
This file contains 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
from teams.models import Team | |
from zipcodes.models import ZipCode, County | |
Z = list(ZipCode.objects.all()) | |
for team in Team.objects.all(): | |
for zip_code in team.zip_codes.all(): | |
if zip_code in Z: | |
Z.remove(zip_code) | |
for county in team.counties.all(): |
OlderNewer