[Grok-dev] Re: absolute url for 'static' ?

Sebastian Ware sebastian at urbantalk.se
Thu May 1 15:09:44 EDT 2008


I solved it by adding the storage utility... this is basically the  
code if someone is stuck with the same problem. I will try to write a  
howto soon.

from z3c.blobfile.file import File
from z3c.blobfile.storages import StringStorable

class AddMyFile(grok.AddForm):
     title = 'Add file'
     form_fields = grok.AutoFields(File)

     @grok.action('Add')
     def action(self, **data):
         site = grok.getSite()
         file = File()
         self.applyData(file, **data)
         site["file_%s" % len(site.keys())] = file

class MyFileStorageUtility(grok.GlobalUtility, StringStorable):
     grok.name('__builtin__.str')

Mvh Sebastian

1 maj 2008 kl. 18.59 skrev Sebastian Ware:

> I am slowly getting there :) but I am getting a  
> ComponentLookupError. Should I add an IStorage utility somewhere?
>
> 2008-05-01T18:57:22 ERROR SiteError http://localhost:8080/test/addmyfile
> Traceback (most recent call last):
>  File "/Users/jhsware/groksandbox/eggs/tmpcxvxyR/ 
> zope.publisher-3.5.0a1.dev_r78838-py2.4.egg/zope/publisher/ 
> publish.py", line 133, in publish
>  File "/Users/jhsware/groksandbox/eggs/tmpSWwOvD/grok-0.12-py2.4.egg/ 
> grok/publication.py", line 45, in callObject
>  File "/Users/jhsware/groksandbox/eggs/tmpA7SqhR/ 
> zope.app.publication-3.4.2-py2.4.egg/zope/app/publication/ 
> zopepublication.py", line 167, in callObject
>  File "/Users/jhsware/groksandbox/eggs/tmpcxvxyR/ 
> zope.publisher-3.5.0a1.dev_r78838-py2.4.egg/zope/publisher/ 
> publish.py", line 108, in mapply
>   - __traceback_info__: <blobtester.app.AddMyFile object at 0x2c67790>
>  File "/Users/jhsware/groksandbox/eggs/tmpcxvxyR/ 
> zope.publisher-3.5.0a1.dev_r78838-py2.4.egg/zope/publisher/ 
> publish.py", line 114, in debug_call
>  File "/Users/jhsware/groksandbox/eggs/tmpSWwOvD/grok-0.12-py2.4.egg/ 
> grok/components.py", line 499, in __call__
>  File "/Users/jhsware/groksandbox/eggs/tmpSWwOvD/grok-0.12-py2.4.egg/ 
> grok/components.py", line 471, in update_form
>  File "/Users/jhsware/groksandbox/eggs/zope.formlib-3.4.0-py2.4.egg/ 
> zope/formlib/form.py", line 754, in update
>    result = action.success(data)
>  File "/Users/jhsware/groksandbox/eggs/tmpSWwOvD/grok-0.12-py2.4.egg/ 
> grok/formlib.py", line 18, in success
>  File "/Users/jhsware/groksandbox/BlobTester/src/blobtester/app.py",  
> line 25, in action
>    file = File()
>  File "/Users/jhsware/groksandbox/eggs/tmpeq_Bap/z3c.blobfile-0.1.0- 
> py2.4.egg/z3c/blobfile/file.py", line 40, in __init__
>  File "/Users/jhsware/groksandbox/eggs/tmpeq_Bap/z3c.blobfile-0.1.0- 
> py2.4.egg/z3c/blobfile/file.py", line 50, in _setData
>  File "/Users/jhsware/groksandbox/eggs/zope.component-3.4.0- 
> py2.4.egg/zope/component/_api.py", line 207, in getUtility
>    raise ComponentLookupError(interface, name)
> ComponentLookupError: (<InterfaceClass  
> z3c.blobfile.interfaces.IStorage>, '__builtin__.str')
>
> Mvh Sebastian
>
> 1 maj 2008 kl. 17.37 skrev Douglas Cerna:
>
>> Hi Sebastian:
>>
>>> I have been exploring z3c.blobfile and zodb.blob, but they
>>> don't
>>> really show how to write code that actually uses the stuff,
>>> the
>>> blobfile doctest uses the ordinary file implementation. How
>>> do I
>>> configure where the storage is done? Where is the missing
>>> document or
>>> sample code? Usually one can figure something out by
>>> looking at the
>>> tests, but here I am at a total loss.
>>
>> Have you check megrok.form?
>>
>> http://svn.zope.org/*checkout*/megrok.form/trunk/src/megrok/form/README.txt
>>
>> It has these two widgets:
>>
>> - BlobFile, from collective.namedblobfile
>> - BlobImage, from collective.namedblobfile
>>
>> The package is not "perfect", but maybe it can give you a start  
>> about using blobs.
>>
>> Douglas
>>
>> "... allí  es cuando te das cuenta que las cosas malas pueden  
>> resultar bastante buenas..." - Lionel Messi
>>
>> Por favor, evite enviarme adjuntos de Word, Excel o PowerPoint.
>> Vea http://www.gnu.org/philosophy/no-word-attachments.es.html
>>
>>
>>
>>      
>> ____________________________________________________________________________________
>> Be a better friend, newshound, and
>> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list