~facundo/ubuntuone-client/fix-svfilenew-conflict

« back to all changes in this revision

Viewing changes to ubuntuone/eventlog/zg_listener.py

  • Committer: Facundo Batista
  • Date: 2011-04-04 12:31:43 UTC
  • mfrom: (922.1.9 ubuntuone-client)
  • Revision ID: facundo@taniquetil.com.ar-20110404123143-mobua5abcpinz0o2
TrunkĀ mergedĀ in

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import mimetypes
21
21
 
 
22
from os.path import basename
 
23
 
22
24
from zeitgeist.datamodel import Event, Interpretation, Manifestation, Subject
23
25
from zeitgeist.mimetypes import get_interpretation_for_mimetype
24
26
 
58
60
 
59
61
    def handle_AQ_CREATE_SHARE_OK(self, share_id, marker):
60
62
        """Log the 'directory shared thru the server' event."""
61
 
        share = self.vm.shared[share_id]
 
63
        share_id = str(share_id)
 
64
        share = self.vm.shared.get(share_id)
 
65
        if not share:
 
66
            share = self.vm.marker_share_map[marker]
 
67
            share_id = share.node_id
62
68
        self.log_folder_shared(share, share_id)
63
69
 
64
70
    def handle_AQ_SHARE_INVITATION_SENT(self, marker):
69
75
 
70
76
    def log_folder_shared(self, share, share_id):
71
77
        """Log the 'directory shared' event."""
72
 
        fullpath = self.fsm.get_abspath(share_id, share.path)
 
78
        fullpath = share.path
 
79
        folder_name = basename(fullpath)
73
80
 
74
81
        folder = Subject.new_for_values(
75
82
            uri=URI_PROTOCOL_U1 + str(share.node_id),
76
83
            interpretation=Interpretation.FOLDER,
77
84
            manifestation=Manifestation.REMOTE_DATA_OBJECT,
78
85
            origin="file:///" + fullpath,
 
86
            text=folder_name,
79
87
            mimetype=DIRECTORY_MIMETYPE,
80
88
            storage=STORAGE_NETWORK)
81
89
 
83
91
        other_user = Subject.new_for_values(
84
92
            uri="mailto:" + other_username,
85
93
            interpretation=INTERPRETATION_U1_CONTACT,
 
94
            text=other_username,
86
95
            manifestation=MANIFESTATION_U1_CONTACT_DATA_OBJECT)
87
96
 
88
97
        event = Event.new_for_values(
100
109
            interpretation=Interpretation.FOLDER,
101
110
            manifestation=Manifestation.REMOTE_DATA_OBJECT,
102
111
            origin="file:///" + share.path,
 
112
            text=basename(share.path),
103
113
            mimetype=DIRECTORY_MIMETYPE,
104
114
            storage=STORAGE_NETWORK)
105
115
 
107
117
        other_user = Subject.new_for_values(
108
118
            uri="mailto:" + other_username,
109
119
            interpretation=INTERPRETATION_U1_CONTACT,
 
120
            text=other_username,
110
121
            manifestation=MANIFESTATION_U1_CONTACT_DATA_OBJECT)
111
122
 
112
123
        event = Event.new_for_values(
126
137
            interpretation=Interpretation.FOLDER,
127
138
            manifestation=Manifestation.REMOTE_DATA_OBJECT,
128
139
            origin="file:///" + share.path,
 
140
            text=basename(share.path),
129
141
            mimetype=DIRECTORY_MIMETYPE,
130
142
            storage=STORAGE_NETWORK)
131
143
 
133
145
        other_user = Subject.new_for_values(
134
146
            uri="mailto:" + other_username,
135
147
            interpretation=INTERPRETATION_U1_CONTACT,
 
148
            text=other_username,
136
149
            manifestation=MANIFESTATION_U1_CONTACT_DATA_OBJECT)
137
150
 
138
151
        event = Event.new_for_values(
150
163
            interpretation=Interpretation.FOLDER,
151
164
            manifestation=Manifestation.REMOTE_DATA_OBJECT,
152
165
            origin="file:///" + share.path,
 
166
            text=basename(share.path),
153
167
            mimetype=DIRECTORY_MIMETYPE,
154
168
            storage=STORAGE_NETWORK)
155
169
 
157
171
        other_user = Subject.new_for_values(
158
172
            uri="mailto:" + other_username,
159
173
            interpretation=INTERPRETATION_U1_CONTACT,
 
174
            text=other_username,
160
175
            manifestation=MANIFESTATION_U1_CONTACT_DATA_OBJECT)
161
176
 
162
177
        event = Event.new_for_values(
174
189
            interpretation=Interpretation.FOLDER,
175
190
            manifestation=Manifestation.DELETED_RESOURCE,
176
191
            origin="file:///" + volume.path,
 
192
            text=basename(volume.path),
177
193
            mimetype=DIRECTORY_MIMETYPE,
178
194
            storage=STORAGE_DELETED)
179
195
 
199
215
            interpretation=Interpretation.FOLDER,
200
216
            manifestation=Manifestation.REMOTE_DATA_OBJECT,
201
217
            origin="file:///" + udf.path,
 
218
            text=basename(udf.path),
202
219
            mimetype=DIRECTORY_MIMETYPE,
203
220
            storage=STORAGE_NETWORK)
204
221
 
218
235
            interpretation=Interpretation.FOLDER,
219
236
            manifestation=Manifestation.FILE_DATA_OBJECT,
220
237
            origin=URI_PROTOCOL_U1 + str(udf.node_id),
 
238
            text=basename(udf.path),
221
239
            mimetype=DIRECTORY_MIMETYPE,
222
240
            storage=STORAGE_LOCAL)
223
241
 
237
255
            interpretation=Interpretation.FOLDER,
238
256
            manifestation=Manifestation.DELETED_RESOURCE,
239
257
            origin=URI_PROTOCOL_U1 + str(udf.node_id),
 
258
            text=basename(udf.path),
240
259
            mimetype=DIRECTORY_MIMETYPE,
241
260
            storage=STORAGE_DELETED)
242
261
 
282
301
            interpretation=interp,
283
302
            manifestation=Manifestation.REMOTE_DATA_OBJECT,
284
303
            origin="file:///" + path,
 
304
            text=basename(path),
285
305
            mimetype=mime,
286
306
            storage=STORAGE_NETWORK)
287
307
 
304
324
            interpretation=Interpretation.FOLDER,
305
325
            manifestation=Manifestation.REMOTE_DATA_OBJECT,
306
326
            origin="file:///" + path,
 
327
            text=basename(path),
307
328
            mimetype=DIRECTORY_MIMETYPE,
308
329
            storage=STORAGE_NETWORK)
309
330
 
338
359
            interpretation=interp,
339
360
            manifestation=Manifestation.FILE_DATA_OBJECT,
340
361
            origin=URI_PROTOCOL_U1 + str(node_id),
 
362
            text=basename(path),
341
363
            mimetype=mime,
342
364
            storage=STORAGE_LOCAL)
343
365
 
360
382
            interpretation=Interpretation.FOLDER,
361
383
            manifestation=Manifestation.FILE_DATA_OBJECT,
362
384
            origin=URI_PROTOCOL_U1 + str(node_id),
 
385
            text=basename(path),
363
386
            mimetype=DIRECTORY_MIMETYPE,
364
387
            storage=STORAGE_LOCAL)
365
388
 
384
407
            interpretation=interp,
385
408
            manifestation=Manifestation.DELETED_RESOURCE,
386
409
            origin=URI_PROTOCOL_U1 + str(node_id),
 
410
            text=basename(old_path),
387
411
            mimetype=mime,
388
412
            storage=STORAGE_DELETED)
389
413
 
409
433
            interpretation=interp,
410
434
            manifestation=Manifestation.DELETED_RESOURCE,
411
435
            origin="file:///" + old_path,
 
436
            text=basename(old_path),
412
437
            mimetype=mime,
413
438
            storage=STORAGE_DELETED)
414
439
 
429
454
            interpretation=interp,
430
455
            manifestation=Manifestation.FILE_DATA_OBJECT,
431
456
            origin="file:///" + old_name,
 
457
            text=basename(new_name),
432
458
            mimetype=mime,
433
459
            storage=STORAGE_LOCAL)
434
460
 
447
473
            interpretation=Interpretation.FOLDER,
448
474
            manifestation=Manifestation.FILE_DATA_OBJECT,
449
475
            origin="file:///" + old_name,
 
476
            text=basename(new_name),
450
477
            mimetype=DIRECTORY_MIMETYPE,
451
478
            storage=STORAGE_LOCAL)
452
479
 
478
505
            interpretation=interp,
479
506
            manifestation=Manifestation.REMOTE_DATA_OBJECT,
480
507
            origin=origin,
 
508
            text=public_url,
481
509
            mimetype=mime,
482
510
            storage=STORAGE_NETWORK)
483
511
 
500
528
            uri=public_url,
501
529
            interpretation=interp,
502
530
            manifestation=Manifestation.DELETED_RESOURCE,
 
531
            text=public_url,
503
532
            origin=origin,
504
533
            mimetype=mime,
505
534
            storage=STORAGE_DELETED)