Author: dmeyer
Date: Fri Sep 7 13:54:43 2007
New Revision: 2801
Log:
clean up scheme and url in dir stuff
Modified:
trunk/beacon/src/client.py
trunk/beacon/src/db.py
trunk/beacon/src/file.py
trunk/beacon/src/server/parser.py
trunk/beacon/src/server/server.py
Modified: trunk/beacon/src/client.py
==============================================================================
--- trunk/beacon/src/client.py (original)
+++ trunk/beacon/src/client.py Fri Sep 7 13:54:43 2007
@@ -133,7 +133,8 @@
return None
if isinstance(url, unicode):
url = kaa.strutils.unicode_to_str(url)
- kwargs['scheme'] = url[:url.find('://')]
+ if url.find('://') > 0:
+ kwargs['scheme'] = url[:url.find('://')]
kwargs['name'] = url
i = Item(None, url, kwargs, parent, parent._beacon_media)
rpc = self.rpc('item.create', type=type, parent=parent._beacon_id,
**kwargs)
Modified: trunk/beacon/src/db.py
==============================================================================
--- trunk/beacon/src/db.py (original)
+++ trunk/beacon/src/db.py Fri Sep 7 13:54:43 2007
@@ -56,12 +56,21 @@
from file import File as create_file
from item import create_item
+# The db uses the following helper functions to create the correct item
+# create_item (not a file or directory)
+# create_file (file or directory, based on parameter)
+# create_directory (directory)
+# create_by_type (item, file or directory based on data)
+
def create_by_type(data, parent, overlay=False, isdir=False):
- if data.get('scheme') not in (None, 'file'):
+ # if the data indicates it is not a file or the parent is not
+ # a directory, make it an Item, not a File.
+ if (data.get('name').find('://') > 0) or (parent and not parent.isdir()):
return create_item(data, parent)
return create_file(data, parent, overlay, isdir)
def create_directory(data, parent):
+ # create directory item
return create_file(data, parent, isdir=True)
class Database(object):
@@ -231,7 +240,8 @@
while pos < len(items) and f > items[pos]._beacon_name:
# file deleted
i = items[pos]
- if i.get('scheme') not in (None, 'file'):
+ if not i.isdir() and not i.isfile():
+ # A remote URL in the directory
pos += 1
continue
items.remove(i)
@@ -252,7 +262,8 @@
if pos + 1 < len(items):
# deleted files at the end
for i in items[pos+1-len(items):]:
- if i.get('scheme') not in (None, 'file'):
+ if not i.isdir() and not i.isfile():
+ # A remote URL in the directory
continue
items.remove(i)
if self.delete_object:
Modified: trunk/beacon/src/file.py
==============================================================================
--- trunk/beacon/src/file.py (original)
+++ trunk/beacon/src/file.py Fri Sep 7 13:54:43 2007
@@ -94,8 +94,8 @@
Item.__init__(self, id, 'file://' + filename, data, parent, media)
if self._beacon_data.get('scheme'):
- self.url = self._beacon_data.get('scheme') + \
- self.url[self.url.find('://')+3:]
+ # file uses a special scheme like dvd
+ self.url = self._beacon_data.get('scheme') + '://' + filename
self._beacon_overlay = overlay
self._beacon_isdir = isdir
Modified: trunk/beacon/src/server/parser.py
==============================================================================
--- trunk/beacon/src/server/parser.py (original)
+++ trunk/beacon/src/server/parser.py Fri Sep 7 13:54:43 2007
@@ -96,9 +96,10 @@
"""
mtime = item._beacon_mtime()
if mtime == None:
- if item._beacon_data.get('scheme') in (None, 'file'):
+ if item.isdir() or item.isfile():
log.warning('no mtime, skip %s' % item)
return 0
+ # neither dir nor file, it can not have a mtime
image = item._beacon_data.get('image')
if image and os.path.exists(image):
t = thumbnail.Thumbnail(image, item._beacon_media)
Modified: trunk/beacon/src/server/server.py
==============================================================================
--- trunk/beacon/src/server/server.py (original)
+++ trunk/beacon/src/server/server.py Fri Sep 7 13:54:43 2007
@@ -91,7 +91,8 @@
width = (int, ATTR_SIMPLE),
height = (int, ATTR_SIMPLE),
length = (float, ATTR_SIMPLE),
- scheme = (int, ATTR_SIMPLE))
+ scheme = (int, ATTR_SIMPLE),
+ date = (int, ATTR_SEARCHABLE))
self.register_file_type_attrs("audio",
title = (unicode, ATTR_KEYWORDS | ATTR_IGNORE_CASE),
@@ -101,7 +102,8 @@
samplerate = (int, ATTR_SIMPLE),
length = (float, ATTR_SIMPLE),
bitrate = (int, ATTR_SIMPLE),
- trackno = (int, ATTR_SIMPLE))
+ trackno = (int, ATTR_SIMPLE),
+ date = (int, ATTR_SEARCHABLE))
self.register_file_type_attrs("image",
width = (int, ATTR_SEARCHABLE),
@@ -109,7 +111,7 @@
comment = (unicode, ATTR_KEYWORDS | ATTR_IGNORE_CASE),
rotation = (int, ATTR_SIMPLE),
author = (unicode, ATTR_SIMPLE),
- date = (unicode, ATTR_SEARCHABLE))
+ date = (int, ATTR_SEARCHABLE))
# tracks for rom discs or iso files
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog