Re: Schema provider/CA lookup status

Martin Aspeli <[email protected]> Thu, 27 Jul 2006 06:58:52 -0700 (PDT)
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <[email protected]>

Sidnei da Silva-2 wrote:
> 
> On Thu, Jul 27, 2006 at 06:02:16AM -0700, Martin Aspeli wrote:
> | This brings me to the performance question. Rob suggested
> | VariableSchemaSupport is very slow. Given that it hashes and caches the
> | schema (once per Zope re-start I guess, since it's a module-level
> variable)
> 
> IIRC, there was an issue with the cache key generated and it would
> always miss and thus re-generate the value.
> 

So here's what it does:

schemadict={}

    def getAndPrepareSchema(self):
        s = self.getSchema()

        # create a hash value out of the schema
        hash=sha.new(str([f.__dict__ for f in s.values()]) +
                     str(self.__class__)).hexdigest()

        if schemadict.has_key(hash): #ok we had that schema already, so take
it
            schema=schemadict[hash]
        else: #make a new one and store it using the hash key
            schemadict[hash]=s
            schema=schemadict[hash]
            g=VarClassGen(schema)
            g.generateClass(self.__class__) #generate the methods

        return schema

So, I guess the use of [f.__dict__ for f in s.values()] is not a good hash?
If this were fixed, could you see any other problems?

I'm a bit worried about the difference between VariableSchemaSupport.py's
ClassGen derivative and the base class - they seem to be a bit out of sync.
If we were happy about any performance implications, though, we could easily
weave the schema cache/lookup/re-generate functionality from VSS into
ClassGen and BaseObject on the schema-by-interface branch. (for my own
product, I could use a custom mixin for now)

Martin
-- 
View this message in context: http://www.nabble.com/Schema-provider-CA-lookup-status-tf1921614.html#a5521536
Sent from the Archetypes - devel forum at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV