Форум сайта python.su
class ClassProblem(models.Model):
classproblem = models.CharField((u'Название класса поломки'),max_length=30)
def __unicode__(self):
return u'%s ' % (self.classproblem)
User.add_to_class('classproblem',models.ManyToManyField(ClassProblem, blank=True))
Unhandled exception in thread started by
Error in sys.excepthook:
<здесь пустые строки>
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x2fe37a0c>> ignored
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x2ac0caac>> ignored
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x303c992c>> ignored
class Adesc(models.Model):
aname = models.CharField(max_length=300)
def __unicode__(self):
return self.aname
class Linker(models.Model):
link = models.ManyToManyField(Adesc, through='SymVes')
name = models.CharField(max_length=128, verbose_name = "Название")
linkA = models.ForeignKey('Alphabet', verbose_name = "Алфавит") #!не важно
linkR = models.ManyToManyField("Razdel", verbose_name = "В разделах") #важно, но не так
def __unicode__(self):
return self.name
class SymVes(models.Model):
symptom = models.ForeignKey(Adesc)
linker = models.ForeignKey(Linker)
vesves = models.CharField(max_length=1, choices=VES_CHOICES, default = 1)
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonDebug On
PythonAutoReload Off
PythonPath "['htdocs', 'C:/Python25/lib/site-packages/django'] + sys.path"
</Location>
<Location "/static/">
SetHandler None
</Location>
# -*- coding: cp1251 -*-
import wx
class TreeGroup(wx.TreeCtrl):
def __init__(self, parent):
wx.TreeCtrl.__init__(self, parent, style=wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|wx.TR_MULTIPLE)
root_id = self.AddRoot('root')
self.AppendItem(root_id, 'grup1')
self.AppendItem(root_id, 'grup2')
self.AppendItem(root_id, 'grup3')
self.UnselectAll()
class MultiChoiceGroup(wx.Dialog):
""" диалог выбора групп для фильтрации списка пользователей
"""
def __init__(self):
wx.Dialog.__init__(self, None, title='Выбор групп', size=(300, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
# Создать панель и дерево
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(wx.StaticText(self, label='Отметьте группы по которым установить фильтр'), flag=wx.ALL, border=10)
################################################################
self.tree = TreeGroup(self)
################################################################
sizer.Add(self.tree, proportion=1, flag=wx.EXPAND|wx.ALL, border=10)
self.SetSizer(sizer)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
self.but_ok = wx.Button(self, label='Ok')
self.but_cancel = wx.Button(self, label='Cancel')
hsizer.Add(self.but_ok, flag=wx.RIGHT, border=5)
hsizer.Add(self.but_cancel)
sizer.Add(hsizer, flag=wx.ALIGN_RIGHT|wx.RIGHT|wx.BOTTOM, border=10)
#
self.but_ok.Bind(wx.EVT_BUTTON, self.OnOk)
self.but_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
acceltbl = wx.AcceleratorTable([
(wx.ACCEL_NORMAL, wx.WXK_RETURN, self.but_ok.GetId()),
(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, self.but_cancel.GetId()),
])
self.SetAcceleratorTable(acceltbl)
def OnOk(self, evt):
self.EndModal(wx.ID_OK)
def OnCancel(self, evt):
self.EndModal(wx.ID_CANCEL)
class App(wx.App):
def __init__(self):
wx.App.__init__(self, True, 'log.txt')
dlg = MultiChoiceGroup()
dlg.ShowModal()
dlg.Destroy()
if __name__ == "__main__":
app = App()
app.MainLoop()
скрипт почему то не принял..
import fcgi
count=0
while fcgi.isFCGI():
request = fcgi.Accept()
request.out.write("Cache-control: no-cache")
request.out.write("Content-Type: text/plain\n\n")
request.out.write("python fastcgi example\n")
request.out.write("counter: "+str(count)+"\n")
count+=1
request.Finish();
import fcgi
count=0
while fcgi.isFCGI():
request = fcgi.Accept()
print "Content-Type: text/plain\n"
print "sgsdg"
request.Finish()
def __getattribute__(self, name):
check = object.__getattribute__(self, '_Proxy__check')
check()
PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
class Author(models.Model):
name = models.CharField(max_length=150)
surname = models.CharField(max_length=60)
def __unicode__(self):
return u'%s %s ' % (self.name, self.surname)
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.ManyToManyField(Author)
price = models.DecimalField("", max_digits=7, decimal_places=2)
def get_entry_author(self):
entry = Book.objects.get(id='self.id')
return entry.authors.all()
get_entry_author.short_description = 'Author'
def __unicode__(self):
return u'%s ' % (self.title)
class BookAdmin(admin.ModelAdmin):
fieldsets = [
('Name book',{'fields': ['title']}),
('Publisher information', {'fields': ['publisher']}),
('Publication date', {'fields': ['publication_date']}),
('Price', {'fields': ['price']}),
('Author', {'fields': ['author']}),
]
list_display = ('title', 'publisher', 'publication_date','price', 'get_entry_author',)
list_filter = ['title']
date_hierarchy = 'publication_date'
class AuthorAdmin(admin.ModelAdmin):
fieldsets=[
('Author information',{'fields':('name', 'surname')}),
]
list_display = ('name', 'surname', )
admin.site.register(Book,BookAdmin)
admin.site.register(Author, AuthorAdmin)
def get_entry_author(self):
entry = Book.objects.get(id='self.id')
return entry.authors.all()
get_entry_author.short_description = 'Author'