I'm a bit swamped right now so I haven't looked into this. I'll need to dig
through the code but I know that there are places where we rely on the
subtypes to determine things like subscriptions and downloadable products.
It's a bit kludgy in places though to be perfectly honest. I need to re-look
at it but just need to get more than 24 hours in a day or get rid of the
pesky need for sleep :)

-Chris

On Wed, Oct 28, 2009 at 3:33 PM, Bob Waycott <[email protected]> wrote:

> It'd be nice to hear from Chris or Bruce on what the purpose of
> _get_subtype() is for, and why it's getting fired. I'm not running on the
> latest Satchmo, and I don't get this error with our current store.
>
> I'd like to dig into it more to figure out what about the model inheritance
> method is being tripped up here. Since MyProduct is a subclass of Product,
> it seems to be trying to run _get_subtypes() from the Product class, and
> perhaps there is something funky happening there? As in, it's running
> _get_subtypes() but there aren't any subtypes for MyProduct?
>
> I'm just guessing here as it's a bit confusing to me why I can't duplicate
> this behavior.
>
>
> On Wed, Oct 28, 2009 at 3:31 PM, philosophe <[email protected]> wrote:
>
>>
>> I had this working previously, or rather I found a workaround for it
>> that now fails.
>>
>> I used the satchmo diaries example for creating a custom product
>> class, and my code starting throwing the _get_subtype() errors:
>>
>> http://groups.google.com/group/satchmo-users/browse_thread/thread/adfff4982affea9f/d063a7d5cd6e2ca7
>>
>> my class looks like this:
>> ####################
>> class MyProduct(Product):
>>        objects = ProductManager()
>>
>>        field1 = models.CharField(_("Field #1"), max_length=100)
>>        field2 = models.CharField(_("Field #2"), max_length=100)
>>
>>        def __unicode__(self):
>>                return self.name
>>
>>        def _get_subtype(self):
>>                print " _get_subtype"
>>                return "MyProduct"
>>
>>        class Meta:
>>                verbose_name = _('This is my Special Product')
>>                verbose_name_plural = _('These are my Special Products')
>> ####################
>>
>> 1. With the above class, I get a loop repeatedly calling _get_subtype)
>> _ until the server crashes
>>
>> 2. if I remove the _get_subtype() method, I get the error "Caught an
>> exception while rendering: 'MyProduct' object has no attribute
>> '_get_subtype'"
>>
>> 3. if i change the return value to "My Product", i get the error
>> 'Product' object has no attribute 'cozybit product'
>> (this was my previous workaround... I was able to create and access
>> products built from this class)
>>
>>
>> the error for #2 pointed to this code from the Product model:
>>    def get_subtypes(self):
>>        # If we've already computed it once, let's not do it again.
>>        # This is a performance speedup.
>>        if hasattr(self,"_sub_types"):
>>            return self._sub_types
>>        types = []
>>        try:
>>            for key in config_value('PRODUCT', 'PRODUCT_TYPES'):
>>                app, subtype = key.split("::")
>>                try:
>>                    subclass = getattr(self, subtype.lower())
>>                    gettype = getattr(subclass, '_get_subtype')
>>                    subtype = gettype()
>>                    if not subtype in types:
>>                        types.append(subtype)
>>                except models.ObjectDoesNotExist:
>>                    pass
>>        except SettingNotSet:
>>            log.warn("Error getting subtypes, OK if in SyncDB")
>>
>>        self._sub_types = tuple(types)
>>        return self._sub_types
>>
>> The product class doesn't have a _get_subtype) method, but the other
>> product classes do.
>>
>> I've deleted the product and rebuilt the db and run syncdb each time I
>> get a failure with this. What should I be looking at?
>>
>> thanks,
>> --derek
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to