Re: AW: move / migrate files to and from mediadb

Niels Dettenbach <[email protected]> Wed, 17 Jul 2013 12:39:28 +0200
Newsgroups gmane.comp.cms.zms.devel
Organization Syndicat IT&Internet
Message-ID <1487144.DiR64cqV2e@gongo>
--nextPart1847356.pQnxs2zOVA
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

Dear Dr. Hoffmann,


Am Freitag, 12. Juli 2013, 17:41:08 schrieben Sie:
> Usually setObjProperty/attr() writes into the declared file system folder -
> provided the mediafolder option is active.
hmm,
i thought so too, but this is not working for me with files of type file (DT_FILE) (i use it for mp3 files) but for image fields it does. 


But i think i got it by diggin into ZMSGlobals.py:

If a file is generated by FileFromData it is instanciated with mediadbStorable=False

If i change this to True i get the resulting file with attr() / setObjProperty() saved within the mediadb storage.

Not shure if this is correct/usuable at all or gives any bad side effects (seems not to me so far) - if it is OK you may use my diff as a fix:


-- zms/ZMSGlobals.py   2012-12-06 19:19:10.000000000 +0100
+++ Products/zms/ZMSGlobals.py  2013-07-17 12:29:33.770442799 +0200
@@ -157,7 +157,7 @@
     # --------------------------------------------------------------------------
     #  ZMSGlobals.FileFromData:
     # --------------------------------------------------------------------------
-    def FileFromData( self, data, filename='', content_type=None):
+    def FileFromData( self, data, filename='', content_type=None, mediadbStorable=False):
       """
       Creates a new instance of a file from given data.
       @param data: File-data (binary)
@@ -171,7 +171,7 @@
       file['data'] = data
       file['filename'] = filename
       if content_type: file['content_type'] = content_type
-      return _blobfields.createBlobField( self, _globals.DT_FILE, file=file, mediadbStorable=False)
+      return _blobfields.createBlobField( self, _globals.DT_FILE, file=file, mediadbStorable=mediadbStorable)
 
 
     # --------------------------------------------------------------------------
@@ -1633,4 +1633,4 @@
 # does the right thing with the security assertions.
 Globals.InitializeClass(ZMSGlobals)



many thanks.
best regards,



Niels.


-- 
 ---
 Niels Dettenbach
 Syndicat IT & Internet
 http://www.syndicat.com
 PGP: https://syndicat.com/pub_key.asc
 ---
 




--nextPart1847356.pQnxs2zOVA
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAABCAAGBQJR5nRkAAoJEM78prARigUn8FwQAKr27fam9DGZ1JjOB+DF2ymm
UFwga2W+x6UDt9sKqi1WCZiWqONN3l0w7fr2Cx3CAJXJ75mk217CRjRjxD9XeYfP
6EBKOqfQU7XPX9pMWaB0y/9RCAPAdTiiGhvqRryTxZzULMDdzg9XoL27YI2PIysT
GHBy+DGcJv3yYHqSmuqqgoVvbjTwc2dpa67GdR1LBi74PWykRTAjT5LR/Lb+LPe4
QjcpaCMhq2QuIkN7MlpMxu8hl60kE1+M8m9RQ8tXmumeTuGZI50DExbmdisIyYkS
iJkOisahH2s4KnDhaUREM7nnMTRv2F++Pp5r9SsmG22wNsBxA32gUIPUOwCL5d2u
Aif5y/7xYdaSH6LOhl4BeiYmB4zMgudEUAw/z74kkFnxEHK1rAOpjvXc6i8TnQUA
49Wrg/3aBjRHIT/NuiPBv3iVvkVRO32dRAsBXuR3BHzrCY5wgZh9AoSSwT8OhVDu
zLbQztQB6oK66pDbQrepWFIloIZQtNSPTzIaB0qG7UFMhuOv0X0yWLFONLXC0M2a
gPnLweGv/lH7mK8lCGiYyYKAoMA6c/QVyccAZ8yQqgFqGWJAv7fjIO3nPvqzkJ5G
Ncy6m19S60pQRGWGKjPGRxADNd2fMlwWuM2YdExx3THle095DyqY1veDn3Mx8RcT
HJxoRllhwmKv1bkpDR3d
=a2mn
-----END PGP SIGNATURE-----

--nextPart1847356.pQnxs2zOVA--