Skip to content

Instantly share code, notes, and snippets.

View hub-cap's full-sized avatar

Michael Basnight hub-cap

View GitHub Profile
2013-04-24 06:22:57 1225 DEBUG reddwarf.openstack.common.processutils [-] Result was 2 execute /home/ubuntu/reddwarf/reddwarf/openstack/common/processutils.py:116
2013-04-24 06:22:57 ERROR reddwarf.openstack.common.rpc.amqp [req-a48b8f3b-e313-433a-ac3a-4e8fd1451f92 radmin c8943e673e7a475a8dbce025c80bc3ba] Exception during message handling
2013-04-24 06:22:57 1225 TRACE reddwarf.openstack.common.rpc.amqp Traceback (most recent call last):
2013-04-24 06:22:57 1225 TRACE reddwarf.openstack.common.rpc.amqp File "/home/ubuntu/reddwarf/reddwarf/openstack/common/rpc/amqp.py", line 277, in _process_data
2013-04-24 06:22:57 1225 TRACE reddwarf.openstack.common.rpc.amqp rval = self.proxy.dispatch(ctxt, version, method, **args)
2013-04-24 06:22:57 1225 TRACE reddwarf.openstack.common.rpc.amqp File "/home/ubuntu/reddwarf/reddwarf/openstack/common/rpc/dispatcher.py", line 147, in dispatch
2013-04-24 06:22:57 1225 TRACE reddwarf.openstack.common.rpc.amqp return getattr(proxyobj, method)(ctxt, **kwargs)
2013-04-
class DatabaseModelBase(models.ModelBase):¬
_auto_generated_attrs = ['id']¬
_uuid_strategy = utils.generate_uuid¬
¬
@classmethod¬
def create(cls, **values):¬
if 'id' not in values and cls._uuid_strategy is not None:¬
values['id'] = uuid_strategy()¬
>>> class A(object):
... _something = 'foo'
...
>>> class B(A):
... _something = 'bar'
... @classmethod
... def foo(cls):
... print cls._something
...
>>> B.foo()
class DatabaseModelBase(models.ModelBase):¬
_auto_generated_attrs = ['id']¬
_uuid_strategy = uuidutils.generate_uuid¬
¬
@classmethod¬
def create(cls, **values):¬
print cls¬
print cls._uuid_strategy
print cls._uuid_strategy()
>>> from reddwarf.db import models
>>> models.DatabaseModelBase
<class 'reddwarf.db.models.DatabaseModelBase'>
>>> models.DatabaseModelBase._uuid_strategy
<unbound method DatabaseModelBase.generate_uuid>
import time
class Foo(object):
@classmethod
def foo(cls):
print "ZOMG"
class Bar(object):
_foo = time.clock
from reddwarf.openstack.common import uuidutils¬
class DatabaseModelBase(models.ModelBase):¬
_auto_generated_attrs = ['id']¬
_uuid_strategy = uuidutils.generate_uuid¬
print _uuid_strategy¬
MF507ZDF8X:reddwarf mbasnigh$ .tox/py27/bin/python
Python 2.7.2 (default, Mar 19 2012, 17:26:47)
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.10.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from reddwarf.db import models; models.DatabaseModelBase._uuid_strategy
<function generate_uuid at 0x10912dcf8>
<unbound method DatabaseModelBase.generate_uuid>
>>> from reddwarf.db import models; models.DatabaseModelBase._uuid_strategy()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
class DatabaseModelBase(models.ModelBase):¬
¬
@classmethod¬
def create(cls, **values):¬
if 'id' not in values:¬
values['id'] = cls.uuid_strategy(**values)¬
if hasattr(cls, 'deleted') and 'deleted' not in values:¬
values['deleted'] = False¬
values['created'] = utils.utcnow()¬
instance = cls(**values).save()¬
class DatabaseModelBase(models.ModelBase):¬
¬
@classmethod¬
def create(cls, **values):¬
values = cls.merge_auto_generated_values(**values)¬
instance = cls(**values).save()¬
if not instance.is_valid():¬
raise exception.InvalidModelError(errors=instance.errors)¬
return instance¬
¬