Hey,<br><br>I think that you are looking for a Factory. <br><br>an example from `Web Component Development with Zope 3` book:<br><br> from zope.component.interfaces import IFactory<br> from zope.interface import implementedBy<br>
<br> class RecipeFactory:<br> implements(IFactory)<br> <br> title = u"Create a new recipe"<br> description = u"This factory instantiates new recipes."<br><br> def __call__(self):<br> return Recipe()<br>
<br> def getInterfaces(self):<br> return implementedBy(Recipe)<br><br><br><utility<br> factory=".recipe.RecipeFactory"<br> name="worldcookery.Recipe"<br> permission="zope.Public"<br>
/><br><br><br>$ bin/debugzope<br>>>> from zope.component import getUtility<br>>>> from zope.component.interfaces import IFactory<br>>>> recipe_factory = getUtility(IFactory, u"worldcookery.Recipe")<br>
>>> weisswurst = recipe_factory()<br>>>> weisswurst<br><worldcookery.recipe.Recipe object at 0x30469c30><br><br><br>I try this myself on grok using grok.GlobalUtility to define the Factory class and avoid the zcml, and works like a charm.<br>
<br>hope it helps<br><br>Regards<br><br><br><div class="gmail_quote">On Fri, Feb 6, 2009 at 12:38 PM, Sebastian Ware <span dir="ltr"><<a href="mailto:sebastian@urbantalk.se">sebastian@urbantalk.se</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If I have a string:<br>
<br>
"<class 'trigger.promotion.Promotion'>"<br>
<br>
can I create an object of the type [trigger.promotion.Promotion]?<br>
<br>
Mvh Sebastian<br>
<br>
<br>
<br>
_______________________________________________<br>
Grok-dev mailing list<br>
<a href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a><br>
<a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Santiago Videla<br><a href="http://www.revolucionesweb.com.ar">www.revolucionesweb.com.ar</a><br><a href="http://www.linkedin.com/in/svidela">http://www.linkedin.com/in/svidela</a><br>
<br>Sigue la mata dando de que hablar siempre abajo y a la izquierda donde el pensamiento que se hace corazón resplandece con la palabra sencilla y humilde que l@s tod@s somos.<br>