Attachment 'link-worksheets.py'

Download

   1 #! /usr/bin/env sage
   2 
   3 import sys
   4 import subprocess
   5 import re
   6 from sagenb.notebook.notebook import Notebook
   7 
   8 zero=r"""
   9 Content of Worksheet Zero
  10 
  11 {{{
  12 2+3
  13 ///
  14 57
  15 }}}
  16 
  17 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam a nibh turpis. Suspendisse potenti. Vivamus a tellus dolor, in consequat risus. Integer non leo libero, vel lobortis dolor. Duis vel urna quis ante tincidunt ultrices sit amet vel felis. Etiam tristique mattis adipiscing. Proin sed nibh metus, non pellentesque tortor. Suspendisse turpis risus, tincidunt id aliquet sed, luctus a erat. Donec volutpat massa ut ante posuere sit amet molestie justo accumsan. Phasellus aliquet nibh purus. Proin eu tristique tellus. Sed libero ligula, euismod nec vehicula eget, gravida eget nulla. Nullam hendrerit mollis malesuada. Donec tincidunt ullamcorper ornare. Aliquam eu adipiscing erat.</p>
  18 
  19 {{{
  20 factor(2010)
  21 ///
  22 }}}
  23 
  24 <p>Quisque bibendum dui eget elit facilisis accumsan. Sed eget augue vel magna iaculis varius id gravida magna. Curabitur elementum commodo odio vel vestibulum. Quisque pulvinar posuere accumsan. Sed blandit dapibus dolor ultricies gravida. Maecenas sed mi sapien, in laoreet quam. Proin luctus nunc quis nulla viverra ut rhoncus velit varius. Nulla eu blandit diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi sed orci at odio iaculis sodales quis sit amet dolor. Praesent vel enim eu nibh molestie vulputate quis id elit. Fusce orci tellus, dapibus quis iaculis et, rutrum non mauris. Phasellus sed nibh odio, nec molestie orci. Etiam adipiscing, velit nec dictum pellentesque, felis massa ullamcorper elit, sed adipiscing nulla libero id ipsum. Maecenas auctor ante sit amet mauris fermentum sed eleifend arcu volutpat.</p>
  25 
  26 <p>A spurious <a href="../1#landing">link</a> to a certain paragraph in the other worksheet (Worksheet 1).</p>
  27 
  28 <p>Sed erat erat, hendrerit sed tincidunt et, malesuada ac diam. Sed sed nibh erat. Maecenas sed sapien neque. Mauris metus lorem, hendrerit et vehicula quis, eleifend in quam. Sed dapibus venenatis mi a lobortis. Curabitur consectetur lacinia turpis, ut posuere urna pulvinar dapibus. In hac habitasse platea dictumst. Vestibulum orci libero, congue vel mattis eu, pulvinar sit amet massa. Integer fermentum fringilla sollicitudin. Quisque posuere dapibus risus, sit amet faucibus dolor faucibus ut. Aliquam fermentum massa non risus viverra fermentum. Cras scelerisque lacinia magna, ac scelerisque turpis tristique id. Suspendisse potenti. Ut accumsan tortor eu orci vehicula vitae malesuada ipsum ultricies. Nulla vehicula leo quis augue scelerisque ut semper risus varius. Praesent suscipit fermentum convallis.</p>
  29 
  30 Praesent venenatis nisi at eros faucibus commodo. Ut tincidunt fringilla congue. Curabitur blandit consequat magna ut facilisis. Fusce sollicitudin leo vitae elit aliquam rhoncus. Aenean fermentum adipiscing felis, at lacinia metus sodales vitae. Vivamus sed neque lacus, sed feugiat tellus. Nulla dui magna, porttitor sed tincidunt ac, molestie luctus arcu. In vitae ligula erat, eget tincidunt augue. Phasellus sit amet ante id tortor commodo lacinia eget vitae justo. Donec feugiat velit id quam pulvinar ut euismod lacus ullamcorper. Sed interdum rutrum arcu, a vehicula velit mollis quis. Aliquam porta elit quam. Vivamus massa ante, consequat vitae commodo eget, posuere imperdiet augue. Quisque neque mi, rutrum at tempus et, posuere quis tortor.
  31 
  32 Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus at purus nec mi fermentum convallis. Praesent in nisl quis justo commodo ultrices. Vivamus eu urna non turpis eleifend gravida. Proin sit amet felis turpis, in suscipit felis. Donec ante sapien, consectetur sed posuere sit amet, bibendum et lorem. Vivamus mattis hendrerit vulputate. Vivamus sodales ipsum at neque suscipit eget malesuada sapien vehicula. Fusce nec convallis nibh. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec porttitor elit fermentum justo ornare placerat. Fusce sapien tortor, tristique non tincidunt eget, tempus quis magna. Mauris imperdiet nisi a mi mattis nec semper dolor rhoncus. Curabitur vel sapien lacus.
  33 """
  34 
  35 one = """
  36 Content of Worksheet One
  37 
  38 {{{
  39 2+3
  40 ///
  41 195
  42 }}}
  43 
  44 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam a nibh turpis. Suspendisse potenti. Vivamus a tellus dolor, in consequat risus. Integer non leo libero, vel lobortis dolor. Duis vel urna quis ante tincidunt ultrices sit amet vel felis. Etiam tristique mattis adipiscing. Proin sed nibh metus, non pellentesque tortor. Suspendisse turpis risus, tincidunt id aliquet sed, luctus a erat. Donec volutpat massa ut ante posuere sit amet molestie justo accumsan. Phasellus aliquet nibh purus. Proin eu tristique tellus. Sed libero ligula, euismod nec vehicula eget, gravida eget nulla. Nullam hendrerit mollis malesuada. Donec tincidunt ullamcorper ornare. Aliquam eu adipiscing erat.</p>
  45 
  46 {{{
  47 factor(2010)
  48 ///
  49 }}}
  50 
  51 <p>Sed erat erat, hendrerit sed tincidunt et, malesuada ac diam. Sed sed nibh erat. Maecenas sed sapien neque. Mauris metus lorem, hendrerit et vehicula quis, eleifend in quam. Sed dapibus venenatis mi a lobortis. Curabitur consectetur lacinia turpis, ut posuere urna pulvinar dapibus. In hac habitasse platea dictumst. Vestibulum orci libero, congue vel mattis eu, pulvinar sit amet massa. Integer fermentum fringilla sollicitudin. Quisque posuere dapibus risus, sit amet faucibus dolor faucibus ut. Aliquam fermentum massa non risus viverra fermentum. Cras scelerisque lacinia magna, ac scelerisque turpis tristique id. Suspendisse potenti. Ut accumsan tortor eu orci vehicula vitae malesuada ipsum ultricies. Nulla vehicula leo quis augue scelerisque ut semper risus varius. Praesent suscipit fermentum convallis.</p>
  52 
  53 <p><a name="landing"></a>This is the landing site for the link from worksheet 0.  Praesent venenatis nisi at eros faucibus commodo. Ut tincidunt fringilla congue. Curabitur blandit consequat magna ut facilisis. Fusce sollicitudin leo vitae elit aliquam rhoncus. Aenean fermentum adipiscing felis, at lacinia metus sodales vitae. Vivamus sed neque lacus, sed feugiat tellus. Nulla dui magna, porttitor sed tincidunt ac, molestie luctus arcu. In vitae ligula erat, eget tincidunt augue. Phasellus sit amet ante id tortor commodo lacinia eget vitae justo. Donec feugiat velit id quam pulvinar ut euismod lacus ullamcorper. Sed interdum rutrum arcu, a vehicula velit mollis quis. Aliquam porta elit quam. Vivamus massa ante, consequat vitae commodo eget, posuere imperdiet augue. Quisque neque mi, rutrum at tempus et, posuere quis tortor.</p>
  54 
  55 <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus at purus nec mi fermentum convallis. Praesent in nisl quis justo commodo ultrices. Vivamus eu urna non turpis eleifend gravida. Proin sit amet felis turpis, in suscipit felis. Donec ante sapien, consectetur sed posuere sit amet, bibendum et lorem. Vivamus mattis hendrerit vulputate. Vivamus sodales ipsum at neque suscipit eget malesuada sapien vehicula. Fusce nec convallis nibh. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec porttitor elit fermentum justo ornare placerat. Fusce sapien tortor, tristique non tincidunt eget, tempus quis magna. Mauris imperdiet nisi a mi mattis nec semper dolor rhoncus. Curabitur vel sapien lacus.</p>
  56 """
  57 
  58 # A notebook with two worksheeets (0, 1) owned by "link"
  59 nb=Notebook("./temp.sagenb")
  60 nb.add_user('link', 'linko', 'nobody@example.com', force=True)
  61 W0 = nb.create_new_worksheet('Zero', 'link')
  62 W1 = nb.create_new_worksheet('One',  'link')
  63 W0.edit_save(zero)
  64 W1.edit_save(one)
  65 #nb.export_worksheet(W.filename(), swsfilename)
  66 #nb.delete()
  67 nb.save()
  68 
  69 # A really temporary, nearly empty notebook
  70 # Just the same user as before (but different credentials)
  71 nbtemp=Notebook("/tmp/junky.sagenb")
  72 nbtemp.add_user('link', 'tempo', 'anybody@nowhere.com', force=True)
  73 nbtemp.save()
  74 
  75 # Copy the ./temp.sagenb/home/link subdirectory
  76 # into /tmp/junky.sagenb/home subdirectory
  77 # essentially re-creating the worksheet collection
  78 # for user  link  into another notebook.
  79 # For testing, then fire-up command-line Sage
  80 # and execute
  81 #    notebook(directory='/tmp/junky.sagenb')
  82 # If you are into the notebook as user "admin" then logout
  83 # and login as "link", with password "tempo"
  84 # and you should see link's two worksheets
  85 # (on first use you will need to creat an admin password)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-02-21 08:16:38, 72.9 KB) [[attachment:approxpoly.pdf]]
  • [get | view] (2010-02-21 08:16:44, 6.8 KB) [[attachment:approxpoly.sws]]
  • [get | view] (2010-02-21 08:16:28, 10.5 KB) [[attachment:approxpoly.tex]]
  • [get | view] (2010-02-21 08:08:10, 266.7 KB) [[attachment:example.pdf]]
  • [get | view] (2010-02-21 08:08:42, 167.8 KB) [[attachment:example.sws]]
  • [get | view] (2010-02-21 08:08:21, 10.6 KB) [[attachment:example.tex]]
  • [get | view] (2010-02-21 07:52:15, 59.0 KB) [[attachment:graphics-test.pdf]]
  • [get | view] (2010-02-21 07:52:00, 8.1 KB) [[attachment:graphics-test.sws]]
  • [get | view] (2010-02-21 07:51:42, 11.1 KB) [[attachment:graphics-test.tex]]
  • [get | view] (2010-01-31 00:49:08, 8.4 KB) [[attachment:link-worksheets.py]]
  • [get | view] (2010-01-31 00:49:16, 2.5 KB) [[attachment:link-worksheets.tar.gz]]
  • [get | view] (2010-02-07 21:46:05, 31.1 KB) [[attachment:math-test.sws]]
  • [get | view] (2010-01-30 23:57:12, 17.3 KB) [[attachment:sage-group-theory-primer.sws]]
  • [get | view] (2010-01-30 23:57:23, 34.7 KB) [[attachment:sage-group-theory-primer.tex]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.