Skip to content

Rhaptos Software Development

Personal tools
You are here: Home » Documentation » System Administration Documentation » Book Printing And Buying

Book Printing And Buying

Document Actions
And overview of the mechanics and administration of PDF generation and print-on-demand ordering.

Configuring Printing

PDF generation for collections is done asynchronously by a special object called the "AsyncPrinter". This can be on any Zope instance, by any name. On cnx.org, it is called /plone/RCPrinter and is present on all front ends. If you visit RCPrinter in the ZMI, you can control which printing code to use and where the printing code performs its data fetching. This may change between machines, and since this object is present through ZEO on all front ends machines, all of them must have the same path to printing code. (The next rollout of printing changes will make this configuration smarter.)

When a Collection is published, it calls via HTTP some AsyncPrint object. We configure where this call goes in /plone/portal_properties/rhaptos_collection_print_config in the ZMI. Two properties 'servicehost' and 'servicepath' point to an AsyncPrint object on some machine. On cnx.org, this is currently cnx.org, so that such requests are distributed amongst front ends.

When these properties are properly set, the publishing collections should trigger a print process successfully.

PDF Management

A Collection may be "locked" to prevent a print process from happening, and thus overwriting the existing PDF (or lack thereof). This is typically used to keep auto-rendered PDFs off of collections with hand-built PDFs, or collections which should not have a PDF. To set the lock status, either:

  1. enter a URL like http://cnx.org/content/col00000/latest/setProcessStatus?value=locked
  2. enter a debug console and call a method like >>> app.plone.content.col10000.latest.setProcessStatus('locked')

The process status value can be "blank", "working", "succeeded", "failed", or "locked". The "succeeded" status is the suggested opposite of "locked".

Note that this will not affect the presence or display of any existing PDFs or the order button. Those are controlled solely by presence or absence of PDFs.

To quickly remove a PDF:

  1. enter a URL like http://cnx.org/content/col00000/latest/setPrintedFile?value=
  2. enter a debug console and call a method like >>> app.plone.content.col10000.latest.setPrintedFile(None)

This is a common operation in combination with locking.

(See also: http://rhaptos.org/docs/sysadmindocs/printoptions)

To add a PDF manually, enter a debug console, read the data of the file into a variable with open() and file.read(), and call setPrintedFile() with that variable as the argument instead of None. This can be seen in the {RhaptosCollection/}printing/batchupload.zctl script, which may be run with zopectl run to upload multiple PDFs to multiple collections. This is a common operation (after offline generation) for system-wide updates to print code.

Multimedia Zip File

This zip file contains all the available media from the collection. It is synchronously generated on first access, then stored on the collection. The link will show up unless:
  1. There is no PDF.
  2. The collection is "locked" and the stored zip file is null.
Thus, if you lock a collection before generating a zip file, the link will not appear. To get one, unlock, click on the multimedia zip link, and the lock again.
More explicitly:

  1. enter a URL like: http://cnx.org/content/col00000/latest/setProcessStatus?value=succeeded
  2. reload the collection page and click on the 'Download Multimedia' link
  3. Relock: http://cnx.org/content/col00000/latest/setProcessStatus?value=locked

This does leave a hole during which a module publish event could trigger a PDF regeneration. Best to workout the equivalent zopectl deubg code, since that could have the unlock/lock steps in one transaction, and not exposed the 'unlocked' state

Multimedia zip files won't be regenerated on locked collections, just like the PDF.

Order Book Button

Note: the specific logic described here could easily change. For the best idea on what will happen, see RhaptosCollection/skins/rhaptos_collection/collection_view.pt, id="cnx_course_buy".

Under certain circumstances, an Order Printed Copy button will appear on Collections. This hooks us to a print-on-demand service to order a hard copy. To configure where this goes, return to /plone/portal_properties/rhaptos_collection_print_config in the ZMI and set the buyBookURLformat property. It expects a URL with a placeholder for the id of the collection. For production use, this value should be:

https://secure-api.qoop.com/Rice/orderprocessing.php?catalog_number=%s

The "%s" in the URL string is replaced by the collection id (like "col10040"). If this property is blank, the system will not show the button in the normal case. See below for exceptions.

The presence of the order button is also controlled on an collection-individual basis by the orderable property. This may currently be set only by Managers and is by default false. It will show up for Managers in the Metadata tab of any collection, published or in workgroups. To get to that page on published collections, since the tabbed edit interface is not normally displayed, add base_edit to an explicit-version collection URL, like http://cnx.org/content/col10363/1.3/base_edit

The orderable property may also be changed like setProcessStatus above, but the method is setOrderable. Values should be any string for "true" or no string at all for "false". Note that the value on a workgroup collection will replace the value on a published collection when it is published, so all workgroup copies should also be set at the same time. [Jenn has a script for this...]
http://cnx.org//content/col0000/latest/setOrderable?value=True
The book ordering button will appear only under the following conditions:

  1. orderable  is true, and
  2. there is a buy link available
    1. ...as a special configuration (see below), or
    2. ...as autogenerated, which requires
      1. a value for buyBookURLformat, and
      2. a PDF available on that collection
      3. the collection be of non-zero size [future]

(Note: The primacy of the orderable condition will probably be removed in the future, making it an additional condition of an auto-generated link.)

Special Ordering Config

Besides the auto-generated PDFs and print-on-demand, we also can specify an ordering website on an individual basis. As seen above, this will over-ride any auto-gen destination for the order button. This can be used to link to special book ordering pages, which can be handy for special covers, books with hand-crafted PDFs, etc.

To set this, see: http://rhaptos.org/docs/sysadmindocs/addbook

Order Page Config

The print-on-demand service consumes a special info page on collection called printinfo, which may be seen on any collection by appending that name to a collection URL, like so:

http://cnx.org/content/col00000/latest/printinfo

It will tell you about the PDF and various other data about the collection, including orderable and processStatus. It supplies two blocks of text used by the printer in the ordering process: buyBookSiteBlurb and buyBookCnxBlurb. These also reside in /plone/portal_properties/rhaptos_collection_print_config and may be edited in the ZMI. (Merely press the Save button, no checkboxes required.)

The buyBookSiteBlurb field contains some non-standard markup that is interpreted by QOOP, so be careful with your edits. Bold is opened with ^b (caret-b) and closed with \b (backslash-b). Line breaks between paragraphs are \n (backslash-n), followed for our convenience by two actual returns in the textarea. The name of the license, or its URL, or something, is represented by the construct %(license)s. (percent sign, "license" in parentheses, followed by "s"). The S isn't literal; it's part of the variable.

If you're worried about messing something up, just make any minor edits directly in the text box, rather than cutting the whole thing into your own text editor and pasting it back in after the edits.

You can see the changes in these properties reflected in the printinfo page immediately.

Created by jccooper
Last modified 2008-08-04 15:30