[Zope3-checkins] CVS: Zope3/src/zope/fssync - fssync.py:1.33 main.py:1.19
Guido van Rossum
guido@python.org
Wed, 11 Jun 2003 11:50:56 -0400
Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv8755
Modified Files:
fssync.py main.py
Log Message:
Added command line options to specify type and factory for 'add' command.
=== Zope3/src/zope/fssync/fssync.py 1.32 => 1.33 ===
--- Zope3/src/zope/fssync/fssync.py:1.32 Tue Jun 10 18:00:11 2003
+++ Zope3/src/zope/fssync/fssync.py Wed Jun 11 11:50:55 2003
@@ -421,7 +421,7 @@
if e and "flag" not in e:
self.diff(t, mode, diffopts)
- def add(self, path):
+ def add(self, path, type=None, factory=None):
if not exists(path):
raise Error("nothing known about '%s'", path)
entry = self.metadata.getentry(path)
@@ -439,6 +439,10 @@
zpath += tail
entry["path"] = zpath
entry["flag"] = "added"
+ if type:
+ entry["type"] = type
+ if factory:
+ entry["factory"] = factory
self.metadata.flush()
if isdir(path):
# Force Entries.xml to exist, even if it wouldn't normally
=== Zope3/src/zope/fssync/main.py 1.18 => 1.19 ===
--- Zope3/src/zope/fssync/main.py:1.18 Tue Jun 10 18:00:11 2003
+++ Zope3/src/zope/fssync/main.py Wed Jun 11 11:50:55 2003
@@ -197,17 +197,35 @@
fs.multiple(args, fs.update)
def add(opts, args):
- """fssync add TARGET ...
+ """fssync add [-t TYPE] [-f FACTORY] TARGET ...
Add the TARGET files or directories to the set of registered
objects. Each TARGET must exist. The next commit will add them
to the Zope 3 server.
+
+ The options -t and -f can be used to set the type and factory of
+ the newly created object; these should be dotted names of Python
+ objects. Usually only the factory needs to be specified.
+
+ If no factory is specified, the type will be guessed when the
+ object is inserted into the Zope 3 server based on the filename
+ extension and the contents of the data. For example, some common
+ image types are recognized by their contents, and the extensions
+ .pt and .dtml are used to create page templates and DTML
+ templates, respectively.
"""
+ type = None
+ factory = None
+ for o, a in opts:
+ if o in ("-t", "--type"):
+ type = a
+ elif o in ("-f", "--factory"):
+ factory = a
if not args:
raise Usage("add requires at least one TARGET argument")
fs = FSSync()
for a in args:
- fs.add(a)
+ fs.add(a, type, factory)
def remove(opts, args):
"""fssync remove TARGET ...
@@ -298,7 +316,7 @@
"co": ("", [], checkout),
"update": ("", [], update),
"commit": ("m:r", ["message=", "raise-on-conflicts"], commit),
- "add": ("", [], add),
+ "add": ("f:t:", ["factory=", "type="], add),
"remove": ("", [], remove),
"rm": ("", [], remove),
"r": ("", [], remove),