1. Ian Schenck
  2. celery-pylons


ianschenck  committed 39ef3af

Put in some documentation

  • Participants
  • Parent commits d0ae1a4
  • Branches default

Comments (0)

Files changed (3)

File celerypylons/__init__.py

View file
+Automatically sets the environment variable `CELERY_LOADER` to
+`celerypylons.loader:PylonsLoader`.  This ensures the loader is
+specified when accessing the rest of this package, and allows celery
+to be installed in a webapp just by importing celerypylons::
+    import celerypylons
+Is this really a good idea?
 import os
 import warnings

File celerypylons/commands.py

View file
 class CeleryCommand(Command):
+    """
+    Abstract Base Class for celery commands.
+    The celery commands are somewhat aggressive about loading
+    celery.conf, and since our module sets the `CELERY_LOADER`
+    environment variable to our loader, we have to bootstrap a bit and
+    make sure we've had a chance to load the pylons config off of the
+    commandline, otherwise everything fails.
+    """
     min_args = 1
     min_args_error = "Please provide a paster config file as an argument."
     takes_config_file = 1
     requires_config_file = True
     def run(self, args):
+        """
+        Overrides Command.run
+        Checks for a config file argument and loads it.
+        """
         if len(args) < self.min_args:
             raise BadCommand(
                 self.min_args_error % {'min_args': self.min_args,
                                        'actual_args': len(args)})            
-        return super(CeleryCommand, self).run(args)
+        return super(CeleryCommand, self).run(args[1:])
     def update_parser(self):
+        """
+        Abstract method.  Allows for the class's parser to be updated
+        before the superclass's `run` method is called.  Necessary to
+        allow options/arguments to be passed through to the underlying
+        celery command.
+        """
         raise NotImplemented("Abstract Method.")
     def bootstrap_config(self, conf):
+        """
+        Loads the pylons configuration.
+        """
         path_to_ini_file = os.path.realpath(conf)
         conf = paste.deploy.appconfig('config:' + path_to_ini_file)
     def command(self):
         from celery.bin import camqadm
-        return camqadm.camqadm(*self.args[1:], **vars(self.options))
+        return camqadm.camqadm(*self.args, **vars(self.options))
 class CeleryEventCommand(CeleryCommand):

File celerypylons/loader.py

View file
 class PylonsLoader(BaseLoader):
-    """Pylons celery loader.
+    """
+    Pylons celery loader.
         * Maps the celery config onto pylons.config