Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

doc update

  • Loading branch information...
commit 99b03853d3ec38c9a36942790c54db4aa60384f1 1 parent 440a55f
Simon Bächler authored
Showing with 75 additions and 3 deletions.
  1. +69 −2 README.rst
  2. +6 −1 scaffolding/__init__.py
71 README.rst
View
@@ -41,5 +41,72 @@ Run the management command to create the data::
manage.py scaffold myapp.MyModel 20
The number stands for the amout of entries to be created.
-
-
+
+
+Using scaffolding in interpreter or views
+=========================================
+
+You can try out the included classes or your own modules in the shell.
+All classes are generators (called Tubes) that generate the field's values.
+start ./manage.py shell::
+
+ >>> from scaffolding import *
+ >>> r=RandInt(min=1, max=5)
+ >>> r.next()
+ [4]
+ >>> r.next()
+ [2]
+
+ >>> n=Name(gender='m')
+ >>> n.next()
+ [u'Ethan Schmid']
+ >>> n.next()
+ [u'Michael Schneider']
+
+
+Included Tubes
+==============
+
+Name
+----
+
+Generates a random name. <gender> can be 'male', 'female', 'm' or 'f'.
+
+LoremIpsum
+----------
+
+Generates a Lorem Ipsum Text. The number of paragraphs is defined in paragraphs.
+
+RandInt
+-------
+
+Generates a random integer between min and max.
+
+RandomInternetImage
+-------------------
+
+Creates a random image for an ImageField using an internet source.
+A Flickr 'Daily Interesting images' grabber is included.
+
+AlwaysTrue
+----------
+
+Returns True
+
+AlwaysFalse
+-----------
+
+Returns False
+
+Contrib
+-------
+
+Crates a Custom Object. The backend class is the first parameter.
+The backend class has to inherit from Tube.
+
+FacebookTestUser
+----------------
+
+Creates a Facebook User from the test users pool of the Facebook app.
+If there aren't enough test users new ones are automatically created.
+
7 scaffolding/__init__.py
View
@@ -47,7 +47,12 @@ def __init__(self, paragraphs=7, max_length=None, text=LOREM_IPSUM, **kwargs):
raise AttributeError('The Text %s only has %s paragraphs' %(text, len(text)))
def next(self):
- text = u'\n\n'.join(self.text[:self.paragraphs])
+ if self.paragraphs < len(self.text):
+ late_start = len(self.text) - self.paragraphs - 1
+ start = random.randint(0, late_start)
+ else:
+ start = 0
+ text = u'\n\n'.join(self.text[start:(start+self.paragraphs)])
if self.max_length:
return text[:self.max_length]
return text
Please sign in to comment.
Something went wrong with that request. Please try again.