equal
deleted
inserted
replaced
101 if source_entity.url: |
101 if source_entity.url: |
102 self.urls = [url.strip() for url in source_entity.url.splitlines() |
102 self.urls = [url.strip() for url in source_entity.url.splitlines() |
103 if url.strip()] |
103 if url.strip()] |
104 else: |
104 else: |
105 self.urls = [] |
105 self.urls = [] |
|
106 |
106 def update_config(self, source_entity, typedconfig): |
107 def update_config(self, source_entity, typedconfig): |
107 """update configuration from source entity. `typedconfig` is config |
108 """update configuration from source entity. `typedconfig` is config |
108 properly typed with defaults set |
109 properly typed with defaults set |
109 """ |
110 """ |
110 self.synchro_interval = timedelta(seconds=typedconfig['synchronization-interval']) |
111 self.synchro_interval = timedelta(seconds=typedconfig['synchronization-interval']) |
288 self.import_log = import_log |
289 self.import_log = import_log |
289 self.stats = {'created': set(), |
290 self.stats = {'created': set(), |
290 'updated': set()} |
291 'updated': set()} |
291 |
292 |
292 def normalize_url(self, url): |
293 def normalize_url(self, url): |
293 from cubicweb.sobjects.parsers import URL_MAPPING |
294 from cubicweb.sobjects import URL_MAPPING # available after registration |
294 for mappedurl in URL_MAPPING: |
295 for mappedurl in URL_MAPPING: |
295 if url.startswith(mappedurl): |
296 if url.startswith(mappedurl): |
296 return url.replace(mappedurl, URL_MAPPING[mappedurl], 1) |
297 return url.replace(mappedurl, URL_MAPPING[mappedurl], 1) |
297 return url |
298 return url |
298 |
299 |
372 is actually deleted. Always return True by default, put more sensible |
373 is actually deleted. Always return True by default, put more sensible |
373 stuff in sub-classes. |
374 stuff in sub-classes. |
374 """ |
375 """ |
375 return True |
376 return True |
376 |
377 |
|
378 def update_if_necessary(self, entity, attrs): |
|
379 self.notify_updated(entity) |
|
380 entity.complete(tuple(attrs)) |
|
381 # check modification date and compare attribute values to only update |
|
382 # what's actually needed |
|
383 mdate = attrs.get('modification_date') |
|
384 if not mdate or mdate > entity.modification_date: |
|
385 attrs = dict( (k, v) for k, v in attrs.iteritems() |
|
386 if v != getattr(entity, k)) |
|
387 if attrs: |
|
388 entity.set_attributes(**attrs) |
|
389 |
|
390 |
377 class DataFeedXMLParser(DataFeedParser): |
391 class DataFeedXMLParser(DataFeedParser): |
378 |
392 |
379 def process(self, url, raise_on_error=False, partialcommit=True): |
393 def process(self, url, raise_on_error=False, partialcommit=True): |
380 """IDataFeedParser main entry point""" |
394 """IDataFeedParser main entry point""" |
381 try: |
395 try: |