[EMAIL PROTECTED] wrote:
> first you need find the bottleneck of your script db or function
> if the bottleneck is db
> 1. which db do you use do you optimize the db from read
> 2. the sql you write do not use any index "maybe select code, type
> from products where type = 'I' or type = 'S' will he
ass Product(object):
> >> __metaclass__ = MetaBase
>
> >> class Item(Product):
> >> def __init__(self, *args, **kw):
> >> self.price = 1
>
> >> class Set(Product):
> >> def __init__(self, *args, **kw):
> >>
Mike Howarth wrote:
> Having overcome my first hurdle with the factory pattern, I've now hit
> another stumbling block
>
> At the moment I'm trying to return around 2000 records from a db and load up
> the relevant product object, what I've found is this is running extremely
> slowly (> 20mins), t
self.price = 2
>>
>> def factory(kind, *args, **kw):
>> return registry[kind](*args, **kw)
>>
>>
>> item = registry['Item']
>
> This returns the Item *class*, not an instance of... So the following:
>
>> print item.pri
>
>> item = registry['Item']
>
> This returns the Item *class*, not an instance of... So the following:
>
>> print item.price
>
> cannot work, since price is an instance attribute, not a class attribute.
>
> What you want is:
>
> item = factory('Item')
> print item.price
>
> HTH
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
View this message in context:
http://www.nabble.com/Factory-pattern-again-tf4156186.html#a11828597
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
Mike Howarth a écrit :
> Hi
>
> I was wondering whether anyone could help me, I'm pretty new to python
> coming from a PHP background and I'm having a few products in getting my
> head round how to write the factory pattern within python.
>
> I'm currently looking to try to return values from a
def factory(kind, *args, **kw):
return registry[kind](*args, **kw)
item = registry['Item']
print item.price
--
View this message in context:
http://www.nabble.com/Factory-pattern-again-tf4156186.html#a11825158
Sent from the Python - python-list mailing list archive at Nab