On Jan 1, 2015, at 9:36 PM, RjOllos wrote:

> > But now we have a problem; clearly in this Template page there is a 
> > 'placeholder' for the attached image, but because it's not attached, 
> > "trac-admin upgrade" won't drag it along for the ride.
> 
> Do you know how the attachments were added to the environment in the first 
> place?  Did the user manually add them to the environment's attachments 
> directory?  If they were added through the Web interface or using TracAdmin, 
> then there should be an entry in the database.

Sadly I don't, and won't until our vacation is over (next Monday)
at the earliest.

> > So unless the user (who is on vacation right now, unfortunately) goes 
> > back and attaches all of these images/docs (on 16 sets of Projects!), 
> > they won't be available in the new 1.0.2 server environment to re-attach 
> > them later. 
>  
> You could script the operations so that the user doesn't have to manually 
> insert the attachments to every environment.
> 
> Before upgrading, you could write a short script to inspect the attachments 
> directory and insert the attachment in the case that there is not a reference 
> to the attachment in the database.  From the directory structure prior to 
> upgrading you know the parent realm, parent resource and resource id of each 
> attachment.  You can use that to construct a query to determine if there is 
> an entry in the attachments table, then insert a row if the entry doesn't 
> exist.
> 
> You probably don't even need to write the queries yourself, you could just 
> use the methods of the Attachment class:
> 
> http://trac.edgewall.org/browser/tags/trac-1.0.2/trac/attachment.py#L121

Probably beyond my meagre understanding of Trac and my Python abilities,
but I'll have a look anyway.

> Another way to script this is to move the existing file out of the 
> attachments directory, and use the TracAdmin command line tool to attach it 
> to the appropriate resource.  This will create the entry in the attachments 
> table and then put the attachment back into the directory.

That sounds a lot more promising!  Because the unattached files/structure
is the same for all these 16 projects, it can probably be scripted.

How do I get the attachment list/realm:id?

--
Trac [/var/trac/projects/test_project]> attachment list
Error: Invalid arguments

attachment list <realm:id>

    List attachments of a resource

    The resource is identified by its realm and identifier.
--

Thanks,

        - Greg

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to