[Grok-dev] Re: access to the parts directory

Christian Theune ct at gocept.com
Fri Apr 25 11:47:14 EDT 2008


On Fri, Apr 25, 2008 at 05:20:51PM +0200, Martijn Faassen wrote:
> Fernando Correa Neto wrote:
>> Hey Joachim,
>>
>> On Fri, Apr 25, 2008 at 3:26 AM, Joachim Schmitz <js at aixtraware.de> wrote:
>>
>>>  I want to have access to subdirectories of my installation, so that my
>>> application can read from or write to them. For example for mass-import of
>>> userdata.
>>
>> Once upon a time, there was a Zope3 branch that would address the
>> zipimport issue but I am not sure how it ended.
>> I am not telling you what to do, but since I don't know any 3rd party
>> product to help you with that, try to play nicelly with your model's
>> __file__ and __path__ attributes and you'll probably come up with
>> something that will solve your problem.
>> But try to do it with security so you don't mess up with your
>> installation and application. If you ask Grok to kill itself, grok you
>> do exactly what you asking for, so....be carefull.
>>
>> Does anyone know something that can deal with file system from zope?
>
> I'm not sure I understand.
>
> Python's 'open()' is a good way to deal with the filesystem from Zope. :)
>
> What I'd do is designate some directory on the system as the directory  
> to import from, perhaps hardcoded in code, or perhaps configurable in  
> the UI (though one needs to be very careful with that from a security  
> perspective).
>
> For mass import you could also upload a zip file and have the  
> application go through that.

True. As a note how to solve his specific question, he can use the products
section in zope.conf generated by buildout:

(this is pseudo-buildout)

zope.conf = ...
    <product-config joachim>
    my-path ${buildout:directory}/parts/foo
    </product-config>


Then in your code, you can retreive this data using:

    import zope.app.appsetup.product
    zope.app.appsetup.product.getProductConfiguration('joachim').get('my-path')

Christian

-- 
gocept gmbh & co. kg - forsterstrasse 29 - 06112 halle (saale) - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development


More information about the Grok-dev mailing list