Subversion Repositories basico

Rev

Rev 356 | Rev 360 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 356 Rev 358
Line 35... Line 35...
35
        Generate new attachment id (same as for annotations)
35
        Generate new attachment id (same as for annotations)
36
        '''
36
        '''
37
        return "%s@T%s" % (sid, str(uuid.uuid4()))
37
        return "%s@T%s" % (sid, str(uuid.uuid4()))
38
38
39
39
40
    def create(self, path, aid):
-
 
-
 
40
    def create(self, path, aid):
41
        sid = self.get_sid(aid)
41
        sid = self.get_sid(aid)
42
        tid = self.gen_tid(sid)
42
        tid = self.gen_tid(sid)
43
        metadata = self.srvutl.get_file_metadata(path)
43
        metadata = self.srvutl.get_file_metadata(path)
44
        metadata['AID'] = aid
44
        metadata['AID'] = aid
45
        metadata['TID'] = tid
45
        metadata['TID'] = tid
46
        metadata['Source'] = path
46
        metadata['Source'] = path
47
        metadata['Created'] = self.srvutl.timestamp()
47
        metadata['Created'] = self.srvutl.timestamp()
-
 
48
        self.log.debug("\tAID: %s", aid)
-
 
49
        self.log.debug("\tTID: %s", tid)
-
 
50
        self.log.debug("\tPath: %s", path)
-
 
51
        self.log.debug("\tCreated: %s", metadata['Created'])
48
        ATTACHMENT_FILE_METADATA = LPATH['ATTACHMENTS'] + tid + '.json'
52
        ATTACHMENT_FILE_METADATA = LPATH['ATTACHMENTS'] + tid + '.json'
49
        ATTACHMENT_FILE_CONTENT = LPATH['ATTACHMENTS'] + tid # No extension needed
53
        ATTACHMENT_FILE_CONTENT = LPATH['ATTACHMENTS'] + tid # No extension needed
50
       
54
       
51
        # copy attachment file to attachemnts database
55
        # copy attachment file to attachemnts database
52
        shutil.copy(path, ATTACHMENT_FILE_CONTENT)
56
        shutil.copy(path, ATTACHMENT_FILE_CONTENT)