Форум сайта python.su
conn = HTTPSConnection(server)
conn.request('POST',path,body,params)
response = conn.getresponse()
data = response.read()
class Photo(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
object = generic.GenericForeignKey('content_type', 'object_id')
image = models.ImageField(upload_to=get_upload_to, max_length=1024)
class Common(models.Model):
# Поля...
photo = generic.GenericRelation(Photo)
class Class_common(Common):
# Поля...
class Class_car(Class_common):
# Поля...
Class_car.objects.get(pk=1).photo.all()
SELECT "media_photo"."id",
"media_photo"."content_type_id",
"media_photo"."object_id",
"media_photo"."image",
FROM "media_photo"
WHERE ("media_photo"."object_id" = 1 AND "media_photo"."content_type_id" = 41 )
Class_car.objects.filter(photo__isnull=False)
SELECT DISTINCT T6."id",
"advert_class_car"."class_common_ptr_id",
FROM "advert_class_car"
INNER JOIN "advert_class_common" ON ("advert_class_car"."class_common_ptr_id" = "advert_class_common"."common_ptr_id")
INNER JOIN "common_common" ON ("advert_class_common"."common_ptr_id" = "common_common"."id")
INNER JOIN "media_photo" ON ("common_common"."id" = "media_photo"."object_id")
INNER JOIN "common_common" T6 ON ("advert_class_car"."class_common_ptr_id" = T6."id")
WHERE ("media_photo"."id" IS NOT NULL AND "media_photo"."content_type_id" = 130 )
// keep this handle handy as we need it for further RIL commands
HRIL rilHandle;
...
HRESULT hr = RIL_Initialize(
1, // index of the RIL port to use (e.g., 1 for RIL1:)
&resultCallBack, // this is a pointer to your result call back method
¬ifyCallback, // this is a pointer to your notify call back method
RIL_NCLASS_ALL, // all notification (except device specific)
(DWORD) this, // custom param (could be a pointer to an instance of a class)
&rilHandle); // returned handle to RIL instance
...
void CALLBACK resultCallback(
DWORD dwCode,
HRESULT hrCmdID,
const void *lpData,
DWORD cbData,
DWORD dwParam)
{
// handle the results
...
void CALLBACK notifyCallback(
DWORD dwCode,
const void *lpData,
DWORD cbData,
DWORD dwParam)
{
// handle the notification
#! /usr/bin/env python
from vsws import url_pattern, Controller
from webob import Request, Response
@url_pattern("/users")
@url_pattern("/all_users")
@url_pattern("/users/${username}/list", ['GET'])
def get_users (response):
response.status = 200
return "Inside get_users()"
@url_pattern("/users/${username}")
def get_user (username):
return {"body": "Inside get_user('%s')" % username, "status": 201}
@url_pattern("/users/${username}/plans", ['GET', 'PUT'])
def get_plans (username):
return "Inside get_plans('%s'), GET or PUT" % username
@url_pattern("/users/${username}/plans", ['POST'])
def get_plans (username):
return "Inside get_plans('%s'), POST" % username
@url_pattern("/users/${username}/plans/${year}")
def get_plan (username, year, method, param2 = ''):
return "Inside get_plan('%s', %s, %s, %s)" % (username, year, method, param2)
print Request.blank ('/users/john/plans/2009?param1=value1¶m2=value2').get_response (Controller())
import threading
def proc(p):
print "Start thread " + p
p1 = threading.Thread(target=proc, name="p1", args=["1"])
p2 = threading.Thread(target=proc, name="p2", args=["2"])
p1.start()
p2.start()
ERROR: dbgp.client:
The main thread of this application is exiting while there are still threads
alive. When the main thread exits, it is system defined whether the other
threads survive.
See Caveats at http://docs.python.org/lib/module-thread.html