On Thursday 04 September 2008 01:59:47 Doug Latornell wrote:
> Something's not quite right, I think, because
>
> $ paster quickstart Foo
> $ paster quickstart -e Foo
> $ paster quickstart --elixir
>
> all yield a model/__init__.py file with import elixir, etc. in it.  I
> would expect the last 2 to do that, but the first command should
> produce an app without elixir.
>
> I had a quick look at r5349 quickstart.py and can't see what the
> problem is.

Ok, I created the attached patch. I can't commit that from work (no SSH, thus 
no SVN), but maybe somebody else can apply it, or you can test it at least.

I don't know much about paster - but to me it looks as if we will run into the 
same problem the very moment we e.g. start supporting sqlobject - 

{{if sqlalchemy}}

will also be True, even if it is set to "False". Unless there is something I 
don't know about, but I didn't find anything using grep in the sources that 
appeared to make sqlalchemy something special elixir as argument isn't.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Index: devtools/commands/quickstart.py
===================================================================
--- devtools/commands/quickstart.py	(revision 5350)
+++ devtools/commands/quickstart.py	(working copy)
@@ -12,7 +12,7 @@
 
 You can use TurboGears2, Pylons, and WebHelper paster commands within the
 project, as well as any paster commands that are provided by a plugin, or you
-create yourself.  
+create yourself.
 
 Usage:
 
@@ -104,7 +104,7 @@
     parser.add_option("--dry-run",
             help="dry run (don't actually do anything)",
             action="store_true", dest="dry_run")
-    parser.add_option("-e", "--elixir", 
+    parser.add_option("-e", "--elixir",
             help="use elixir as ORM.", action="store_true",
             dest="elixir", default = False,)
 
@@ -113,7 +113,6 @@
         """Quickstarts the new project."""
 
         self.__dict__.update(self.options.__dict__)
-
         if not True in [self.elixir, self.sqlalchemy, self.sqlobject]:
             self.sqlalchemy = True
         if self.elixir:
Index: devtools/templates/turbogears/+package+/model/__init__.py_tmpl
===================================================================
--- devtools/templates/turbogears/+package+/model/__init__.py_tmpl	(revision 5350)
+++ devtools/templates/turbogears/+package+/model/__init__.py_tmpl	(working copy)
@@ -3,11 +3,11 @@
 
 from zope.sqlalchemy import ZopeTransactionExtension
 from sqlalchemy.orm import scoped_session, sessionmaker
-{{if not elixir}}
+{{if not elixir == "True"}}
 #from sqlalchemy import MetaData
 from sqlalchemy.ext.declarative import declarative_base
 {{endif}}
-{{if elixir}}
+{{if elixir == "True"}}
 import elixir
 {{endif}}
 
@@ -16,18 +16,18 @@
 maker = sessionmaker(autoflush=True, autocommit=False,
                      extension=ZopeTransactionExtension())
 DBSession = scoped_session(maker)
-
+{{if not elixir == "True"}}
 # By default, the data model is defined with SQLAlchemy's declarative
 # extension, but if you need more control, you can switch to the traditional
 # method.
-{{if not elixir}}
+
 DeclarativeBase = declarative_base()
 
 # Global metadata.
 # The default metadata is the one from the declarative base.
 metadata = DeclarativeBase.metadata
 {{endif}}
-{{if elixir}}
+{{if elixir == "True"}}
 metadata = elixir.metadata
 {{endif}}
 # If you have multiple databases with overlapping table names, you'll need a
@@ -37,7 +37,7 @@
 #####
 # Generally you will not want to define your table's mappers, and data objects
 # here in __init__ but will want to create modules them in the model directory
-# and import them at the bottom of this file.  
+# and import them at the bottom of this file.
 #
 ######
 
@@ -45,20 +45,20 @@
     """Call me before using any of the tables or classes in the model."""
 
     DBSession.configure(bind=engine)
-    {{if elixir}}
+    {{if elixir == "True"}}
     metadata.bind = engine
-    {{endif}}    
-    # If you are using reflection to introspect your database and create 
-    # table objects for you, your tables must be defined and mapped inside 
-    # the init_model function, so that the engine is available if you 
+    {{endif}}
+    # If you are using reflection to introspect your database and create
+    # table objects for you, your tables must be defined and mapped inside
+    # the init_model function, so that the engine is available if you
     # use the model outside tg2, you need to make sure this is called before
-    # you use the model. 
+    # you use the model.
 
     #
-    # See the following example: 
-    
+    # See the following example:
+
     #global t_reflected
-    
+
     #t_reflected = Table("Reflected", metadata,
     #    autoload=True, autoload_with=engine)
 
@@ -66,13 +66,13 @@
 
 {{endif}}
 
-# Import your model modules here. 
+# Import your model modules here.
 
 {{if identity == "sqlalchemy"}}
 from identity import User, Group, Permission
 {{endif}}
 
-{{if elixir}}
+{{if elixir == "True"}}
 # setup the elixir models
 elixir.setup_all()
 {{endif}}
\ No newline at end of file
Index: devtools/templates/turbogears/+package+/model/identity.py_tmpl
===================================================================
--- devtools/templates/turbogears/+package+/model/identity.py_tmpl	(revision 5350)
+++ devtools/templates/turbogears/+package+/model/identity.py_tmpl	(working copy)
@@ -1,5 +1,5 @@
 {{if identity == "sqlalchemy"}}
-{{if not elixir}}
+{{if not elixir == "True"}}
 import md5
 import sha
 from datetime import datetime
@@ -37,17 +37,17 @@
     """An ultra-simple group definition.
     """
     __tablename__ = 'tg_group'
-    
+
     group_id = Column(Integer, autoincrement=True, primary_key=True)
-    
+
     group_name = Column(Unicode(16), unique=True)
-    
+
     display_name = Column(Unicode(255))
-    
+
     created = Column(DateTime, default=datetime.now)
-    
+
     users = relation('User', secondary=user_group_table, backref='groups')
-    
+
     def __repr__(self):
         return '<Group: name=%s>' % self.group_name
 
@@ -57,19 +57,19 @@
     attributes.
     """
     __tablename__ = 'tg_user'
-    
+
     user_id = Column(Integer, autoincrement=True, primary_key=True)
-    
+
     user_name = Column(Unicode(16), unique=True)
-    
+
     email_address = Column(Unicode(255), unique=True)
-    
+
     display_name = Column(Unicode(255))
-    
+
     _password = Column('password', Unicode(40))
-    
+
     created = Column(DateTime, default=datetime.now)
-    
+
     def __repr__(self):
         return '<User: email="%s", display name="%s">' % (
                 self.email_address, self.display_name)
@@ -164,17 +164,17 @@
     """A relationship that determines what each Group can do
     """
     __tablename__ = 'tg_permission'
-    
+
     permission_id = Column(Integer, autoincrement=True, primary_key=True)
-    
+
     permission_name = Column(Unicode(16), unique=True)
-    
+
     description = Column(Unicode(255))
-    
+
     groups = relation(Group, secondary=group_permission_table,
                       backref='permissions')
 {{endif}}
-{{if elixir}}
+{{if elixir == "True"}}
 
 from sqlalchemy.orm import scoped_session, sessionmaker
 from datetime import datetime
@@ -203,7 +203,7 @@
     using_options(tablename="tg_user", auto_primarykey="user_id")
 
     user_name = Field(Unicode(16), required=True, unique=True)
-    
+
     email_address = Field(Unicode(255), required=True, unique=True)
 
     display_name = Field(Unicode(255))
@@ -219,7 +219,7 @@
         local_colname="group_id",
         remote_colname="user_id",
         )
-    
+
     def __repr__(self):
         return '<User: email="%s", display name="%s">' % (
                 self.email_address, self.display_name)
@@ -315,13 +315,13 @@
     """An ultra-simple group definition.
     """
     using_options(tablename="tg_group", auto_primarykey="group_id")
-    
+
     group_name = Field(Unicode(16), unique=True)
-    
+
     display_name = Field(Unicode(255))
-    
+
     created = Field(DateTime, default=datetime.now)
-    
+
     users = ManyToMany("User")
 
     permissions = ManyToMany(
@@ -340,12 +340,12 @@
     """A relationship that determines what each Group can do
     """
     using_options(tablename="tg_permission", auto_primarykey="permission_id")
-    
+
     permission_name = Field(Unicode(16), unique=True)
-    
+
     description = Field(Unicode(255))
 
     groups = ManyToMany("Group")
-    
+
 {{endif}}
 {{endif}}

Reply via email to